From: Charlie Jenkins <charlie@rivosinc.com>
To: Alexandre Ghiti <alex@ghiti.fr>
Cc: Shuah Khan <shuah@kernel.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Samuel Holland <samuel.holland@sifive.com>,
linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org,
Palmer Dabbelt <palmer@rivosinc.com>
Subject: Re: [PATCH v2] riscv: selftests: Fix warnings pointer masking test
Date: Thu, 5 Dec 2024 13:31:59 -0800 [thread overview]
Message-ID: <Z1Ibz-j8LUad571l@ghost> (raw)
In-Reply-To: <697a402b-0305-489d-bf4e-aa5e7fa4b2aa@ghiti.fr>
On Thu, Dec 05, 2024 at 09:11:46AM +0100, Alexandre Ghiti wrote:
> Hi Charlie,
>
> On 05/12/2024 03:57, Charlie Jenkins wrote:
> > When compiling the pointer masking tests with -Wall this warning
> > is present:
> >
> > pointer_masking.c: In function ‘test_tagged_addr_abi_sysctl’:
> > pointer_masking.c:203:9: warning: ignoring return value of ‘pwrite’
> > declared with attribute ‘warn_unused_result’ [-Wunused-result]
> > 203 | pwrite(fd, &value, 1, 0); |
> > ^~~~~~~~~~~~~~~~~~~~~~~~ pointer_masking.c:208:9: warning:
> > ignoring return value of ‘pwrite’ declared with attribute
> > ‘warn_unused_result’ [-Wunused-result]
> > 208 | pwrite(fd, &value, 1, 0);
> >
> > I came across this on riscv64-linux-gnu-gcc (Ubuntu
> > 11.4.0-1ubuntu1~22.04).
> >
> > Fix this by checking that the number of bytes written equal the expected
> > number of bytes written.
> >
> > Fixes: 7470b5afd150 ("riscv: selftests: Add a pointer masking test")
> > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> > ---
> > Changes in v2:
> > - I had ret != 2 for testing, I changed it to be ret != 1.
> > - Link to v1: https://lore.kernel.org/r/20241204-fix_warnings_pointer_masking_tests-v1-1-ea1e9665ce7a@rivosinc.com
> > ---
> > tools/testing/selftests/riscv/abi/pointer_masking.c | 19 +++++++++++++++----
> > 1 file changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/testing/selftests/riscv/abi/pointer_masking.c b/tools/testing/selftests/riscv/abi/pointer_masking.c
> > index dee41b7ee3e3..229d85ccff50 100644
> > --- a/tools/testing/selftests/riscv/abi/pointer_masking.c
> > +++ b/tools/testing/selftests/riscv/abi/pointer_masking.c
> > @@ -189,6 +189,7 @@ static void test_tagged_addr_abi_sysctl(void)
> > {
> > char value;
> > int fd;
> > + int ret;
> > ksft_print_msg("Testing tagged address ABI sysctl\n");
> > @@ -200,14 +201,24 @@ static void test_tagged_addr_abi_sysctl(void)
> > }
> > value = '1';
> > - pwrite(fd, &value, 1, 0);
> > + ret = pwrite(fd, &value, 1, 0);
> > + if (ret != 1) {
> > + ksft_test_result_fail("Write to /proc/sys/abi/tagged_addr_disabled failed.\n");
> > + return;
> > + }
> > +
> > ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == -EINVAL,
> > "sysctl disabled\n");
> > value = '0';
> > - pwrite(fd, &value, 1, 0);
> > - ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == 0,
> > - "sysctl enabled\n");
> > + ret = pwrite(fd, &value, 1, 0);
> > + if (ret != 1) {
> > + ksft_test_result_fail("Write to /proc/sys/abi/tagged_addr_disabled failed.\n");
> > + return;
> > + }
> > +
> > + ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == -EINVAL,
> > + "sysctl disabled\n");
>
> Why did you change the test from 0 to -EINVAL here?
Thank you for pointing that out, copy-paste issue, I will revert that change!
- Charlie
>
> Thanks,
>
> Alex
>
>
> > set_tagged_addr_ctrl(0, false);
> >
> > ---
> > base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
> > change-id: 20241204-fix_warnings_pointer_masking_tests-3860e4f35429
prev parent reply other threads:[~2024-12-05 21:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 2:57 [PATCH v2] riscv: selftests: Fix warnings pointer masking test Charlie Jenkins
2024-12-05 8:04 ` Andrew Jones
2024-12-05 11:15 ` Alexandre Ghiti
2024-12-05 12:25 ` Andrew Jones
2024-12-05 21:30 ` Charlie Jenkins
2024-12-05 21:40 ` Charlie Jenkins
2024-12-05 8:11 ` Alexandre Ghiti
2024-12-05 21:31 ` Charlie Jenkins [this message]
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=Z1Ibz-j8LUad571l@ghost \
--to=charlie@rivosinc.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=samuel.holland@sifive.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