Skip to contentSkip to conversation

perf build x86: Fix SC2034 error in syscalltbl.sh

PATCH Applied Haoze Xie 2 participants 2 messages Jul 7, 2024 – Jul 12, 2024 1 message not in the archive perf events

lore
Share & tools
lore

Haoze Xie

author
#1 lore raw

PATCH 1/1 perf build x86: Fix SC2034 error in syscalltbl.sh

In reply to a message not in the archive

Change the unused var in 'arch/x86/entry/syscalls/syscalltbl.sh' to '_' when reading from '$sorted_table'. This change allows the script to pass tests of ShellCheck before and after version 0.7.2 at the same time.

When building in arch x86, syscalltbl.sh got a ShellCheck warning, which makes compilation error:

In arch/x86/entry/syscalls/syscalltbl.sh line 27:
while read nr _abi name entry _compat; do
^-^ SC2034: abi appears unused.
Verify use (or export if used externally).
^----^ SC2034: compat appears unused.
Verify use (or export if used externally).

The script reads unused param abi and compat. It uses format '_xxx' to indicate dummy vars, which won't work properly when ShellCheck <= 0.7.2.

According to SC2034, the more general way of writing is to use directly '_' to indicate discarding vars. 'entry' is also replaced by '_' because it just happens to be defined in emit function, otherwise it will lead to some misunderstandings.

---
 tools/perf/arch/x86/entry/syscalls/syscalltbl.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/arch/x86/entry/syscalls/syscalltbl.sh +3 -1
index 59d7914ed6bb..2b71f99933a5 100755
@@ -24,7 +24,9 @@ sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX)
 grep '^[0-9]' "$in" | sort -n > $sorted_table
 
 max_nr=0
-while read nr _abi name entry _compat; do
+# the params are: nr abi name entry compat
+# use _ for intentionally unused variables according to SC2034
+while read nr _ name _ _; do
     if [ $nr -ge 512 ] ; then # discard compat sycalls
         break
     fi
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw
Quoted 8 lines · Haoze Xie

Change the unused var in 'arch/x86/entry/syscalls/syscalltbl.sh' to '_' when reading from '$sorted_table'. This change allows the script to pass tests of ShellCheck before and after version 0.7.2 at the same time.

When building in arch x86, syscalltbl.sh got a ShellCheck warning, which makes compilation error:

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung