public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: pahole-version: avoid errors if executing fails
@ 2024-07-28 12:55 Miguel Ojeda
  2024-08-02 23:34 ` Nicolas Schier
  2024-08-22 17:28 ` Masahiro Yamada
  0 siblings, 2 replies; 7+ messages in thread
From: Miguel Ojeda @ 2024-07-28 12:55 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Masahiro Yamada
  Cc: Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	bpf, Nathan Chancellor, Nicolas Schier, linux-kbuild,
	linux-kernel, patches, Miguel Ojeda

Like patch "rust: suppress error messages from
CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT" [1], do not assume the file existing
and being executable implies executing it will succeed. Instead, bail
out if executing it fails for any reason.

For instance, `pahole` may be built for another architecture, may be a
program we do not expect or may be completely broken:

    $ echo 'bad' > bad-pahole
    $ chmod u+x bad-pahole
    $ make PAHOLE=./bad-pahole defconfig
    ...
    ./bad-pahole: 1: bad: not found
    init/Kconfig:112: syntax error
    init/Kconfig:112: invalid statement

Link: https://lore.kernel.org/rust-for-linux/20240727140302.1806011-1-masahiroy@kernel.org/ [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 scripts/pahole-version.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/pahole-version.sh b/scripts/pahole-version.sh
index f8a32ab93ad1..a35b557f1901 100755
--- a/scripts/pahole-version.sh
+++ b/scripts/pahole-version.sh
@@ -5,9 +5,9 @@
 #
 # Prints pahole's version in a 3-digit form, such as 119 for v1.19.
 
-if [ ! -x "$(command -v "$@")" ]; then
+if output=$("$@" --version 2>/dev/null); then
+	echo "$output" | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'
+else
 	echo 0
 	exit 1
 fi
-
-"$@" --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'

base-commit: 256abd8e550ce977b728be79a74e1729438b4948
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-09-02 16:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-28 12:55 [PATCH] kbuild: pahole-version: avoid errors if executing fails Miguel Ojeda
2024-08-02 23:34 ` Nicolas Schier
2024-08-22 17:28 ` Masahiro Yamada
2024-08-23 13:59   ` Nicolas Schier
2024-08-23 18:47     ` Miguel Ojeda
2024-09-02  2:15       ` Masahiro Yamada
2024-09-02 16:11         ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox