From: "Nai-Chen(Simone) Cheng" <bleach1827@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Shuah Khan <shuah@kernel.org>,
netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH] selftests/net: fix unused return value warnings in ksft.h
Date: Tue, 9 Sep 2025 18:00:17 +0800 [thread overview]
Message-ID: <a3d1c5ca-cdce-428d-8c1c-6a1f59e2dd76@gmail.com> (raw)
In-Reply-To: <20250908182018.28d9ff10@kernel.org>
On 2025-09-09 09:20, Jakub Kicinski wrote:
> Is it just a GCC warning or rather a combination of GCC and some
> misguided glibc decorator to force check the return of read/write?
> Naming the compiler versions and the warning flag which enables
> this would be useful. We don't see it building with normal warning
> level today.
Thanks for the review!
I found that the warnings occur under specific build
conditions that explain why it's not consistently seen:
The warning appears when manually cleaning and rebuilding net/lib/:
cd tools/testing/selftests/net/lib/
make clean && make
The warning messages are:
ksft.h: In function ‘ksft_ready’:
ksft.h:27:9: warning: ignoring return value of ‘write’ declared with
attribute ‘warn_unused_result’ [-Wunused-result]
ksft.h: In function ‘ksft_wait’:
ksft.h:51:9: warning: ignoring return value of ‘read’ declared with
attribute ‘warn_unused_result’ [-Wunused-result]
This is triggered by:
- GCC version: 14.2.0
- -Wall flag (which includes -Wunused-result)
During investigation of this unused result warning and following up on
the patch by Minh-Quang Bui [1], I also discovered an issue with the
selftests build system: running 'make clean' from
tools/testing/selftests/ doesn't clean objects in net/lib/ because the
clean target doesn't include $(INSTALL_DEPS_TARGET). This explains why
net/lib compiled objects persist after cleaning and why the warning only
appears with manual cleaning of that specific directory.
> Can you not cast the read() to void directly?
Sure. Direct casting is much cleaner. I haven't noticed it... Thanks for
the advice.
Would it be acceptable to:
1. Send a v2 of this patch with the direct void casting approach and
more precise commit message?
2. Send a separate patch to fix the selftests Makefile clean target to
include $(INSTALL_DEPS_TARGET)?
[1]
https://lore.kernel.org/all/20250601142914.13379-1-minhquangbui99@gmail.com/
Thanks,
Nai-Chen Cheng
next prev parent reply other threads:[~2025-09-09 10:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-06 15:59 [PATCH] selftests/net: fix unused return value warnings in ksft.h Nai-Chen Cheng
2025-09-09 1:20 ` Jakub Kicinski
2025-09-09 10:00 ` Nai-Chen(Simone) Cheng [this message]
2025-09-09 23:25 ` Jakub Kicinski
2025-09-10 11:16 ` Nai-Chen(Simone) Cheng
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=a3d1c5ca-cdce-428d-8c1c-6a1f59e2dd76@gmail.com \
--to=bleach1827@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).