Skip to contentSkip to conversation

devtools: fix false positive from checkpatch

PATCH Superseded Stephen Hemminger 3 participants 6 messages Sep 17, 2024 – Nov 30, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devtools: fix false positive from checkpatch

The codespell dictionary has "stdio" in its bad word list, but stdio.h is often used in DPDK code and creates bogus false postitives from checkpatch.

Also add a check to the parameters to build-dict.sh so it gives usage error if parameter is missing or does not point to the codespell git clone.

---
 devtools/build-dict.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/build-dict.sh +5 -0
index a8cac49029..96786d2c53 100755
@@ -6,6 +6,10 @@
 
 # path to local clone of https://github.com/codespell-project/codespell.git
 codespell_path=$1
+if [ ! -d "$codespell_path/codespell_lib/data" ]; then
+	echo "Usage: $0 <path_to_codespell_project>"
+	exit 1
+fi
 
 # concatenate codespell dictionaries, except GB/US one
 for suffix in .txt _code.txt _informal.txt _names.txt _rare.txt _usage.txt ; do
@@ -17,6 +21,7 @@ sed '/^..->/d' |
 sed '/^uint->/d' |
 sed "/^doesn'->/d" |
 sed '/^wasn->/d' |
+sed '/stdio->/d' |
 
 # print to stdout
 cat
Signature · 1 line
2.45.2
#1 lore raw
Quoted 29 lines · Stephen Hemminger

The codespell dictionary has "stdio" in its bad word list, but stdio.h is often used in DPDK code and creates bogus false postitives from checkpatch.

Also add a check to the parameters to build-dict.sh so it gives usage error if parameter is missing or does not point to the codespell git clone.

---
 devtools/build-dict.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/build-dict.sh +4 -0
index a8cac49029..96786d2c53 100755
@@ -6,6 +6,10 @@
 
 # path to local clone of https://github.com/codespell-project/codespell.git
 codespell_path=$1
+if [ ! -d "$codespell_path/codespell_lib/data" ]; then
+	echo "Usage: $0 <path_to_codespell_project>"
+	exit 1
+fi
 
 # concatenate codespell dictionaries, except GB/US one
 for suffix in .txt _code.txt _informal.txt _names.txt _rare.txt _usage.txt ; do

devtools/build-dict.sh sed '/^..->/d' | · line 25

Quoted 5 lines
devtools/build-dict.sh +1 -0
@@ -17,6 +21,7 @@ sed '/^..->/d' |
 sed '/^uint->/d' |
 sed "/^doesn'->/d" |
 sed '/^wasn->/d' |
+sed '/stdio->/d' |
 

Seems a good idea. However, why use "stdio" alone rather than using the full "stdio.h" header name. Do we expect "stdio" to be used much in comments or otherwise?

/Bruce

#2 lore raw

17/09/2024 17:45, Bruce Richardson:

Quoted 27 lines · Stephen Hemminger
Quoted 26 lines

The codespell dictionary has "stdio" in its bad word list, but stdio.h is often used in DPDK code and creates bogus false postitives from checkpatch.

Also add a check to the parameters to build-dict.sh so it gives usage error if parameter is missing or does not point to the codespell git clone.

---
 devtools/build-dict.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/build-dict.sh +4 -0
index a8cac49029..96786d2c53 100755
@@ -6,6 +6,10 @@
 
 # path to local clone of https://github.com/codespell-project/codespell.git
 codespell_path=$1
+if [ ! -d "$codespell_path/codespell_lib/data" ]; then
+	echo "Usage: $0 <path_to_codespell_project>"
+	exit 1
+fi
 
Quoted 11 lines

devtools/build-dict.sh sed '/^..->/d' | · line 25

Quoted 8 lines
devtools/build-dict.sh +1 -0
 # concatenate codespell dictionaries, except GB/US one
 for suffix in .txt _code.txt _informal.txt _names.txt _rare.txt _usage.txt ; do
@@ -17,6 +21,7 @@ sed '/^..->/d' |
 sed '/^uint->/d' |
 sed "/^doesn'->/d" |
 sed '/^wasn->/d' |
+sed '/stdio->/d' |
 

Seems a good idea. However, why use "stdio" alone rather than using the full "stdio.h" header name. Do we expect "stdio" to be used much in comments or otherwise?

The dictionary doesn't know stdio.h

You could start with a caret to mimic other entries.

#3 lore raw
In reply to Bruce Richardson
Quoted 12 lines · On Tue, 17 Sep 2024 16:45:35 +0100 Bruce Richardson…

devtools/build-dict.sh sed '/^..->/d' | · line 25

Quoted 8 lines
 # concatenate codespell dictionaries, except GB/US one
 for suffix in .txt _code.txt _informal.txt _names.txt _rare.txt _usage.txt ; do
devtools/build-dict.sh +1 -0
@@ -17,6 +21,7 @@ sed '/^..->/d' |
 sed '/^uint->/d' |
 sed "/^doesn'->/d" |
 sed '/^wasn->/d' |
+sed '/stdio->/d' |
 

Seems a good idea. However, why use "stdio" alone rather than using the full "stdio.h" header name. Do we expect "stdio" to be used much in comments or otherwise?

Quoted 1 line

/Bruce

This script removes entries from the codespell dictionary. So we are removing this line:

	stdio->studio

Which causes:
WARNING:TYPO_SPELLING: 'stdio' may be misspelled - perhaps 'studio'?

#4 lore raw

PATCH v2 1/1 devtools: fix false positive from checkpatch

In reply to Stephen Hemminger

The codespell dictionary has "stdio" in its bad word list, but stdio.h is often used in DPDK code and creates bogus false positives from checkpatch.

Also add a check to the parameters to build-dict.sh so it gives usage error if parameter is missing or does not point to the codespell git clone.

---
 devtools/build-dict.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/build-dict.sh +5 -0
index a8cac49029..f2fedd534a 100755
@@ -6,6 +6,10 @@
 
 # path to local clone of https://github.com/codespell-project/codespell.git
 codespell_path=$1
+if [ ! -d "$codespell_path/codespell_lib/data" ]; then
+	echo "Usage: $0 <path_to_codespell_project>"
+	exit 1
+fi
 
 # concatenate codespell dictionaries, except GB/US one
 for suffix in .txt _code.txt _informal.txt _names.txt _rare.txt _usage.txt ; do
@@ -17,6 +21,7 @@ sed '/^..->/d' |
 sed '/^uint->/d' |
 sed "/^doesn'->/d" |
 sed '/^wasn->/d' |
+sed '/^stdio->/d' |
 
 # print to stdout
 cat
Signature · 1 line
2.45.2
#5 lore raw

17/09/2024 18:56, Stephen Hemminger:

Quoted 9 lines

The codespell dictionary has "stdio" in its bad word list, but stdio.h is often used in DPDK code and creates bogus false positives from checkpatch.

Also add a check to the parameters to build-dict.sh so it gives usage error if parameter is missing or does not point to the codespell git clone.

Redirected error message to stderr,
and saved the dict path in a variable to avoid redundancy, and applied, thanks.