|WARNING| pw162372 [PATCH 1/2] eal: add RTE_MIN4 and RTE_MAX4 macros

checkpatch at dpdk.org checkpatch at dpdk.org
Thu Mar 12 01:22:03 CET 2026


Test-Label: checkpatch
Test-Status: WARNING
http://dpdk.org/patch/162372

_coding style issues_


ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#109: FILE: lib/eal/include/rte_common.h:818:
+#define RTE_MIN4(a, b, c, d) \
+	__extension__ ({ \
+		typeof (a) _min4_ab = RTE_MIN((a), (b)); \
+		typeof (c) _min4_cd = RTE_MIN((c), (d)); \
+		RTE_MIN(_min4_ab, _min4_cd); \
+	})

BUT SEE:

   do {} while (0) advice is over-stated in a few situations:

   The more obvious case is macros, like MODULE_PARM_DESC, invoked at
   file-scope, where C disallows code (it must be in functions).  See
   $exceptions if you have one to add by name.

   More troublesome is declarative macros used at top of new scope,
   like DECLARE_PER_CPU.  These might just compile with a do-while-0
   wrapper, but would be incorrect.  Most of these are handled by
   detecting struct,union,etc declaration primitives in $exceptions.

   Theres also macros called inside an if (block), which "return" an
   expression.  These cannot do-while, and need a ({}) wrapper.

   Enjoy this qualification while we work to improve our heuristics.

WARNING:SPACING: space prohibited between function name and open parenthesis '('
#111: FILE: lib/eal/include/rte_common.h:820:
+		typeof (a) _min4_ab = RTE_MIN((a), (b)); \

WARNING:SPACING: space prohibited between function name and open parenthesis '('
#112: FILE: lib/eal/include/rte_common.h:821:
+		typeof (c) _min4_cd = RTE_MIN((c), (d)); \

ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#126: FILE: lib/eal/include/rte_common.h:861:
+#define RTE_MAX4(a, b, c, d) \
+	__extension__ ({ \
+		typeof (a) _max4_ab = RTE_MAX((a), (b)); \
+		typeof (c) _max4_cd = RTE_MAX((c), (d)); \
+		RTE_MAX(_max4_ab, _max4_cd); \
+	})

BUT SEE:

   do {} while (0) advice is over-stated in a few situations:

   The more obvious case is macros, like MODULE_PARM_DESC, invoked at
   file-scope, where C disallows code (it must be in functions).  See
   $exceptions if you have one to add by name.

   More troublesome is declarative macros used at top of new scope,
   like DECLARE_PER_CPU.  These might just compile with a do-while-0
   wrapper, but would be incorrect.  Most of these are handled by
   detecting struct,union,etc declaration primitives in $exceptions.

   Theres also macros called inside an if (block), which "return" an
   expression.  These cannot do-while, and need a ({}) wrapper.

   Enjoy this qualification while we work to improve our heuristics.

WARNING:SPACING: space prohibited between function name and open parenthesis '('
#128: FILE: lib/eal/include/rte_common.h:863:
+		typeof (a) _max4_ab = RTE_MAX((a), (b)); \

WARNING:SPACING: space prohibited between function name and open parenthesis '('
#129: FILE: lib/eal/include/rte_common.h:864:
+		typeof (c) _max4_cd = RTE_MAX((c), (d)); \

total: 2 errors, 4 warnings, 32 lines checked


More information about the test-report mailing list