]> git.ipfire.org Git - thirdparty/linux.git/commit
tools/x86/kcpuid: Fix error handling
authorAhmed S. Darwish <darwi@linutronix.de>
Mon, 24 Mar 2025 14:20:22 +0000 (15:20 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Mar 2025 08:53:43 +0000 (09:53 +0100)
commit116edfe173d0c59ec2aa87fb91f2f31d477b61b3
treee9ef7f9c66c930b7befec2ee69c55c170af2890b
parent2df0c02dab829dd89360d98a8a1abaa026ef5798
tools/x86/kcpuid: Fix error handling

Error handling in kcpuid is unreliable.  On malloc() failures, the code
prints an error then just goes on.  The error messages are also printed
to standard output instead of standard error.

Use err() and errx() from <err.h> to direct all error messages to
standard error and automatically exit the program.  Use err() to include
the errno information, and errx() otherwise.  Use warnx() for warnings.

While at it, alphabetically reorder the header includes.

[ mingo: Fix capitalization in the help text while at it. ]

Fixes: c6b2f240bf8d ("tools/x86: Add a kcpuid tool to show raw CPU features")
Reported-by: Remington Brasga <rbrasga@uci.edu>
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20250324142042.29010-2-darwi@linutronix.de
Closes: https://lkml.kernel.org/r/20240926223557.2048-1-rbrasga@uci.edu
tools/arch/x86/kcpuid/kcpuid.c