[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <14125726-bb00-4de4-87f6-6655b0ffae58@ghiti.fr>
Date: Thu, 5 Dec 2024 12:15:16 +0100
From: Alexandre Ghiti <alex@...ti.fr>
To: Andrew Jones <ajones@...tanamicro.com>,
Charlie Jenkins <charlie@...osinc.com>
Cc: Shuah Khan <shuah@...nel.org>, Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Samuel Holland <samuel.holland@...ive.com>, linux-kselftest@...r.kernel.org,
linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
Palmer Dabbelt <palmer@...osinc.com>
Subject: Re: [PATCH v2] riscv: selftests: Fix warnings pointer masking test
Hi Drew,
On 05/12/2024 09:04, Andrew Jones wrote:
> On Wed, Dec 04, 2024 at 06:57:10PM -0800, 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@...osinc.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;
>> + }
> Could make a wrapper function for pwrite() to avoid duplicating the ret
> value check.
>
>> +
>> + ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == -EINVAL,
>> + "sysctl disabled\n");
> Why is this changed from expecting 0 for the return and being the
> "sysctrl enabled" test? We still write '0' to tagged_addr_disabled here.
>
>>
>> set_tagged_addr_ctrl(0, false);
>>
>>
>> ---
>> base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
>> change-id: 20241204-fix_warnings_pointer_masking_tests-3860e4f35429
>> --
>> - Charlie
>>
> Not part of this patch, but now that I looked at
> test_tagged_addr_abi_sysctl() I see that
> ksft_test_result_skip() is duplicated.
>
> Thanks,
> drew
Your mails often end up in my junk folder, am I the only one? Any idea
what could be wrong?
Thanks,
Alex
>> _______________________________________________
>> linux-riscv mailing list
>> linux-riscv@...ts.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Powered by blists - more mailing lists