diff --git a/include/spdk_internal/mock.h b/include/spdk_internal/mock.h index 8de44ae555..18b1b93276 100644 --- a/include/spdk_internal/mock.h +++ b/include/spdk_internal/mock.h @@ -72,15 +72,19 @@ extern ret ut_ ## fn; \ ret __wrap_ ## fn args; ret __real_ ## fn args -/* for defining the implmentation of wrappers for syscalls */ +/* + * For defining the implementation of wrappers for syscalls. + * Avoid nested macro calls to prevent macro expansion of fn. + */ #define DEFINE_WRAPPER(fn, ret, dargs, pargs) \ - DEFINE_RETURN_MOCK(fn, ret); \ + bool ut_ ## fn ## _mocked = false; \ + ret ut_ ## fn; \ __attribute__((used)) ret __wrap_ ## fn dargs \ { \ if (!ut_ ## fn ## _mocked) { \ return __real_ ## fn pargs; \ } else { \ - return MOCK_GET(fn); \ + return ut_ ## fn; \ } \ }