Help with macro

Morten Brørup mb at smartsharesystems.com
Fri Nov 4 13:13:38 CET 2022


With this macro:

#define RTE_MEMPOOL_CACHE_STAT_ADD(cache, name, n) do { \
		(cache)->stats.name += n;               \
	} while (0)

checkpatch complained: WARNING:SINGLE_STATEMENT_DO_WHILE_MACRO: Single statement macros should not use a do {} while (0) loop


So I reluctantly changed it to this:

#define RTE_MEMPOOL_CACHE_STAT_ADD(cache, name, n) (cache)->stats.name += n

and checkpatch complained: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses


Any suggestions for how to define this macro, without checkpatch throwing a fit?


Med venlig hilsen / Kind regards,
-Morten Brørup




More information about the dev mailing list