From: Simon Horman <horms@kernel.org>
To: Alessandro Zanni <alessandro.zanni87@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, shuah@kernel.org, netdev@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftest: net: Fix error message if empty variable
Date: Thu, 25 Sep 2025 11:49:30 +0100 [thread overview]
Message-ID: <20250925104930.GG836419@horms.kernel.org> (raw)
In-Reply-To: <20250924230413.75246-1-alessandro.zanni87@gmail.com>
On Thu, Sep 25, 2025 at 01:04:07AM +0200, Alessandro Zanni wrote:
> Fix to avoid cases where the `res` shell variable is
> empty in script comparisons.
>
> The issue can be reproduced with the command:
> make kselftest TARGETS=net
>
> It solves the error:
> ./tfo_passive.sh: line 98: [: -eq: unary operator expected
>
> Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
> ---
> tools/testing/selftests/net/tfo_passive.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/tfo_passive.sh b/tools/testing/selftests/net/tfo_passive.sh
> index 80bf11fdc046..2655931b2396 100755
> --- a/tools/testing/selftests/net/tfo_passive.sh
> +++ b/tools/testing/selftests/net/tfo_passive.sh
> @@ -95,7 +95,7 @@ wait
> res=$(cat $out_file)
> rm $out_file
>
> -if [ $res -eq 0 ]; then
> +if [ -n "$res" ] && [ $res -eq 0 ]; then
> echo "got invalid NAPI ID from passive TFO socket"
> cleanup_ns
> exit 1
Hi Alessandro,
I'm not sure what $res can be in practice.
But as it is the contents of $out_file (or more specifically,
the stdout of running cat $outfile), in theory it could be anything.
So while your patch addresses one error case.
I think there are others.
f.e. if res is not empty but not numeric, then we may see
bash: [: b: integer expression expected
Or if res contains a newline, then we may see
bash: [: too many arguments
So I wonder if it is better to treat $res as a string,
and quote it to avoid unexpected side effects.
[ "$res" = "0" ]
next prev parent reply other threads:[~2025-09-25 10:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-24 23:04 [PATCH] selftest: net: Fix error message if empty variable Alessandro Zanni
2025-09-25 10:49 ` Simon Horman [this message]
2025-09-25 12:40 ` Alessandro Zanni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250925104930.GG836419@horms.kernel.org \
--to=horms@kernel.org \
--cc=alessandro.zanni87@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.