Commit a4384085 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

mock.h: apply "used" attribute to DECLARE_WRAPPER, not DEFINE_WRAPPER



Some unit tests such as nvmf/tcp use DECLARE_WRAPPER but then define it
explicitly rather than using DEFINE_WRAPPER.

DEFINE_WRAPPER would apply __attribute__((used)) to the function definition,
nvmf/tcp doesn't have that for its __wrap_RAND_bytes() function, and LTO
would complain.

By applying it to the DECLARE_WRAPPER instead, any users of these macros
get that attribute applied, whether they use DEFINE_WRAPPER or define the
wrapper function themselves.

Fixes issue #3386.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23306

 (master)

(cherry picked from commit 274b06d3)
Change-Id: I072835cc280b9057e1cb7b038d715634e830216f
Signed-off-by: default avatarMarek Chomnicki <marek.chomnicki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23347


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 645e63a8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@
	DECLARE_MOCK_QUEUE(fn, ret); \
	extern bool ut_ ## fn ## _mocked; \
	extern ret ut_ ## fn; \
	ret __wrap_ ## fn args; ret __real_ ## fn args
	__attribute__((used)) ret __wrap_ ## fn args; ret __real_ ## fn args

/*
 * For defining the implementation of wrappers for syscalls.
@@ -100,7 +100,7 @@
 */
#define DEFINE_WRAPPER(fn, ret, dargs, pargs) \
	DEFINE_WRAPPER_MOCK(fn, ret); \
	__attribute__((used)) ret __wrap_ ## fn dargs \
	ret __wrap_ ## fn dargs \
	{ \
		if (!ut_ ## fn ## _mocked) { \
			return __real_ ## fn pargs; \