From: Karel Zak Date: Thu, 26 Feb 2026 10:27:48 +0000 (+0100) Subject: tools/checkconfig: strip C comments before macro extraction X-Git-Tag: v2.43-devel~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2c8a5b82cc4bedd5cebc0ea22fbf967294a5632;p=thirdparty%2Futil-linux.git tools/checkconfig: strip C comments before macro extraction Strip C/C++ comments (// line comments, single-line /* */ and multi-line /* */ blocks) before extracting HAVE_ and ENABLE_ macros. This avoids false positives from macros mentioned in comments, e.g. "when HAVE_PIDFD_* ..." in include/pidfd-utils.h. Signed-off-by: Karel Zak --- diff --git a/tools/checkconfig.sh b/tools/checkconfig.sh index 7a17cd69e..94c159ac9 100755 --- a/tools/checkconfig.sh +++ b/tools/checkconfig.sh @@ -47,9 +47,15 @@ while [ "$#" -ne 0 ]; do # ENABLE_ and HAVE_ macros shouldn't be used for any other purpose than # for config/build options. # - DEFINES=$(sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \ - -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \ - $srcfile | sort -u) + # Strip C/C++ comments to avoid false positives from + # macros mentioned in comments (e.g. "when HAVE_FOO is ...") + DEFINES=$(sed -e 's://.*::' \ + -e 's:/\*.*\*/::g' \ + $srcfile | \ + sed -e '/\/\*/,/\*\//d' | \ + sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \ + -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' | \ + sort -u) [ -z "$DEFINES" ] && continue for d in $DEFINES; do