Skip to contentSkip to conversation

scripts: headers_install: fix a false positive

PATCH Superseded Wen Yang 3 participants 4 messages May 13, 2025 – Jun 30, 2025

lore
Share & tools
lore

Wen Yang

author
#0 lore raw

PATCH 1/1 scripts: headers_install: fix a false positive

The current implementation only handles C89 style comments (/*... */) in the code, and there are false positives for C99 style comments (//...).

This patch fixes this issue.

---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 6bbccb43f7e7..41722bcc8668 100755
@@ -44,6 +44,7 @@ scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
 # Remove /* ... */ style comments, and find CONFIG_ references in code
 configs=$(sed -e '
 :comment
+	s://.*::
 	s:/\*[^*][^*]*:/*:
 	s:/\*\*\**\([^/]\):/*\1:
 	t comment
Signature · 1 line
2.25.1
#1 lore raw
Quoted 24 lines · Wen Yang

The current implementation only handles C89 style comments (/*... */) in the code, and there are false positives for C99 style comments (//...).

This patch fixes this issue.

---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 6bbccb43f7e7..41722bcc8668 100755
@@ -44,6 +44,7 @@ scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
 # Remove /* ... */ style comments, and find CONFIG_ references in code
 configs=$(sed -e '
 :comment
+	s://.*::
 	s:/\*[^*][^*]*:/*:
 	s:/\*\*\**\([^/]\):/*\1:
 	t comment
Signature · 1 line
2.25.1

thanks. The patch looks good to me, but I cannot find any false positives. Have you found any concrete?

Kind regards,
Nicolas

author
#2 lore raw
Quoted 20 lines · Nicolas Schier
Quoted 19 lines · Wen Yang

The current implementation only handles C89 style comments (/*... */) in the code, and there are false positives for C99 style comments (//...).

This patch fixes this issue.

---
  scripts/headers_install.sh | 1 +
  1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 6bbccb43f7e7..41722bcc8668 100755
@@ -44,6 +44,7 @@ scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
  # Remove /* ... */ style comments, and find CONFIG_ references in code
  configs=$(sed -e '
  :comment
+	s://.*::
Quoted 9 lines
Quoted 5 lines
scripts/headers_install.sh +0 -0
  	s:/\*[^*][^*]*:/*:
  	s:/\*\*\**\([^/]\):/*\1:
  	t comment
Signature · 1 line
2.25.1

thanks. The patch looks good to me, but I cannot find any false positives. Have you found any concrete?

Thanks. We have enhanced dmabuf on our SoC platform and modified the include/uapi/linux/dma-buf.h file, and then found this issue.

--
Best wishes,
Wen

#3 lore raw
Quoted 34 lines · Wen Yang
Quoted 20 lines · Nicolas Schier
Quoted 19 lines · Wen Yang

The current implementation only handles C89 style comments (/*... */) in the code, and there are false positives for C99 style comments (//...).

This patch fixes this issue.

---
  scripts/headers_install.sh | 1 +
  1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 6bbccb43f7e7..41722bcc8668 100755
@@ -44,6 +44,7 @@ scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
  # Remove /* ... */ style comments, and find CONFIG_ references in code
  configs=$(sed -e '
  :comment
+    s://.*::
Quoted 9 lines
Quoted 5 lines
scripts/headers_install.sh +0 -1
     s:/\*[^*][^*]*:/*:
     s:/\*\*\**\([^/]\):/*\1:
     t comment
--

2.25.1

thanks. The patch looks good to me, but I cannot find any false positives. Have you found any concrete?

Quoted 2 lines

Thanks. We have enhanced dmabuf on our SoC platform and modified the include/uapi/linux/dma-buf.h file, and then found this issue.

The SPDX License Identifier in UAPI headers use
/* ... */, and never C++ style comments.

In my understanding, the idea behind this is
UAPI headers follow more strict C.

Signature · 2 lines
Best Regards
Masahiro Yamada