[PATCH 6/6] devtools: forbid direct use of sys/queue.h
Stephen Hemminger
stephen at networkplumber.org
Thu Sep 17 19:19:44 CEST 2026
The set of list macros provided by <sys/queue.h> differs per platform:
glibc lacks the _FOREACH_SAFE variants, and musl and Windows have no such
header. DPDK now provides rte_queue.h with the complete set.
Both headers use the same multiple inclusion guard, so a single direct
include of <sys/queue.h> anywhere in a translation unit disables
rte_queue.h for all of it. Reject new occurrences.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
devtools/checkpatches.sh | 9 +++++++++
doc/guides/contributing/coding_style.rst | 5 ++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 18bd825372..a8ff4bfe82 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -105,6 +105,15 @@ check_forbidden_additions() { # <patch>
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
"$1" || res=1
+ # include rte_queue.h, the system header has fewer macros
+ awk -v FOLDERS="lib drivers app examples" \
+ -v SKIP_FILES='lib/eal/include/rte_queue.h' \
+ -v EXPRESSIONS='include.*<sys/queue.h>' \
+ -v RET_ON_FAIL=1 \
+ -v MESSAGE='Using <sys/queue.h>, prefer <rte_queue.h>' \
+ -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+ "$1" || res=1
+
# check %l or %ll format specifier
awk -v FOLDERS='lib drivers app examples' \
-v EXPRESSIONS='%ll*[xud]' \
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 11de3bb39a..f2c2cd8503 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -317,11 +317,14 @@ Queues
~~~~~~
Use queue(3) macros rather than rolling your own lists, whenever possible.
+Include ``<rte_queue.h>`` rather than ``<sys/queue.h>``:
+the set of macros provided by the system header differs per platform,
+and the DPDK one provides the same complete set everywhere.
Thus, the previous example would be better written:
.. code-block:: c
- #include <sys/queue.h>
+ #include <rte_queue.h>
struct foo {
LIST_ENTRY(foo) link; /* Use queue macros for foo lists. */
--
2.53.0
More information about the dev
mailing list