linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] selftests/x86/syscall: fix coccinelle WARNING recommending the use of ARRAY_SIZE()
@ 2024-11-01 11:15 Mirsad Todorovac
  2024-11-01 11:15 ` [PATCH v1 2/2] selftests/mm: " Mirsad Todorovac
  2024-11-01 12:04 ` [PATCH v1 1/2] selftests/x86/syscall: " Muhammad Usama Anjum
  0 siblings, 2 replies; 6+ messages in thread
From: Mirsad Todorovac @ 2024-11-01 11:15 UTC (permalink / raw)
  To: Andrew Morton, Suren Baghdasaryan, Mirsad Todorovac, linux-mm,
	linux-kselftest, linux-kernel
  Cc: Shuah Khan, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin

Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
to improve the code readability:

./tools/testing/selftests/x86/syscall_numbering.c:316:35-36: WARNING: Use ARRAY_SIZE

Fixes: 15c82d98a0f78 ("selftests/x86/syscall: Update and extend syscall_numbering_64")
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
---
 v1: initial version.

 tools/testing/selftests/x86/syscall_numbering.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/x86/syscall_numbering.c b/tools/testing/selftests/x86/syscall_numbering.c
index 991591718bb0..41c42b7b54a6 100644
--- a/tools/testing/selftests/x86/syscall_numbering.c
+++ b/tools/testing/selftests/x86/syscall_numbering.c
@@ -25,6 +25,7 @@
 #include <sys/mman.h>
 
 #include <linux/ptrace.h>
+#include "../kselftest.h"
 
 /* Common system call numbers */
 #define SYS_READ	  0
@@ -313,7 +314,7 @@ static void test_syscall_numbering(void)
 	 * The MSB is supposed to be ignored, so we loop over a few
 	 * to test that out.
 	 */
-	for (size_t i = 0; i < sizeof(msbs)/sizeof(msbs[0]); i++) {
+	for (size_t i = 0; i < ARRAY_SIZE(msbs); i++) {
 		int msb = msbs[i];
 		run("Checking system calls with msb = %d (0x%x)\n",
 		    msb, msb);
-- 
2.43.0



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

* [PATCH v1 2/2] selftests/mm: fix coccinelle WARNING recommending the use of ARRAY_SIZE()
  2024-11-01 11:15 [PATCH v1 1/2] selftests/x86/syscall: fix coccinelle WARNING recommending the use of ARRAY_SIZE() Mirsad Todorovac
@ 2024-11-01 11:15 ` Mirsad Todorovac
  2024-11-01 13:48   ` Peter Xu
  2024-11-01 12:04 ` [PATCH v1 1/2] selftests/x86/syscall: " Muhammad Usama Anjum
  1 sibling, 1 reply; 6+ messages in thread
From: Mirsad Todorovac @ 2024-11-01 11:15 UTC (permalink / raw)
  To: Andrew Morton, Suren Baghdasaryan, Mirsad Todorovac, linux-mm,
	linux-kselftest, linux-kernel
  Cc: Shuah Khan, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Peter Xu

Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
to improve the code readability:

./tools/testing/selftests/mm/uffd-unit-tests.c:1484:32-33: WARNING: Use ARRAY_SIZE
./tools/testing/selftests/mm/uffd-unit-tests.c:1485:30-31: WARNING: Use ARRAY_SIZE

Fixes: 16a45b57cbf2 ("selftests/mm: add framework for uffd-unit-test")
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: linux-mm@kvack.org
Cc: linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
---
 v1: initial version.

 tools/testing/selftests/mm/uffd-unit-tests.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index a2e71b1636e7..4f6a7440a9aa 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -1481,8 +1481,8 @@ static void usage(const char *prog)
 
 int main(int argc, char *argv[])
 {
-	int n_tests = sizeof(uffd_tests) / sizeof(uffd_test_case_t);
-	int n_mems = sizeof(mem_types) / sizeof(mem_type_t);
+	int n_tests = ARRAY_SIZE(uffd_tests);
+	int n_mems = ARRAY_SIZE(mem_types);
 	const char *test_filter = NULL;
 	bool list_only = false;
 	uffd_test_case_t *test;
-- 
2.43.0



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

* Re: [PATCH v1 1/2] selftests/x86/syscall: fix coccinelle WARNING recommending the use of ARRAY_SIZE()
  2024-11-01 11:15 [PATCH v1 1/2] selftests/x86/syscall: fix coccinelle WARNING recommending the use of ARRAY_SIZE() Mirsad Todorovac
  2024-11-01 11:15 ` [PATCH v1 2/2] selftests/mm: " Mirsad Todorovac
@ 2024-11-01 12:04 ` Muhammad Usama Anjum
  2024-11-02 18:55   ` Mirsad Todorovac
  1 sibling, 1 reply; 6+ messages in thread
From: Muhammad Usama Anjum @ 2024-11-01 12:04 UTC (permalink / raw)
  To: Mirsad Todorovac, Andrew Morton, Suren Baghdasaryan, linux-mm,
	linux-kselftest, linux-kernel
  Cc: Usama.Anjum, Shuah Khan, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin

On 11/1/24 4:15 PM, Mirsad Todorovac wrote:
> Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
> to improve the code readability:
> 
> ./tools/testing/selftests/x86/syscall_numbering.c:316:35-36: WARNING: Use ARRAY_SIZE
> 
> Fixes: 15c82d98a0f78 ("selftests/x86/syscall: Update and extend syscall_numbering_64")
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: x86@kernel.org
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-kselftest@vger.kernel.org
> Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> ---
>  v1: initial version.
> 
>  tools/testing/selftests/x86/syscall_numbering.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/x86/syscall_numbering.c b/tools/testing/selftests/x86/syscall_numbering.c
> index 991591718bb0..41c42b7b54a6 100644
> --- a/tools/testing/selftests/x86/syscall_numbering.c
> +++ b/tools/testing/selftests/x86/syscall_numbering.c
> @@ -25,6 +25,7 @@
>  #include <sys/mman.h>
>  
>  #include <linux/ptrace.h>
> +#include "../kselftest.h"
>  
>  /* Common system call numbers */
>  #define SYS_READ	  0
> @@ -313,7 +314,7 @@ static void test_syscall_numbering(void)
>  	 * The MSB is supposed to be ignored, so we loop over a few
>  	 * to test that out.
>  	 */
> -	for (size_t i = 0; i < sizeof(msbs)/sizeof(msbs[0]); i++) {
> +	for (size_t i = 0; i < ARRAY_SIZE(msbs); i++) {
>  		int msb = msbs[i];
>  		run("Checking system calls with msb = %d (0x%x)\n",
>  		    msb, msb);

-- 
BR,
Muhammad Usama Anjum



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

* Re: [PATCH v1 2/2] selftests/mm: fix coccinelle WARNING recommending the use of ARRAY_SIZE()
  2024-11-01 11:15 ` [PATCH v1 2/2] selftests/mm: " Mirsad Todorovac
@ 2024-11-01 13:48   ` Peter Xu
  2024-11-02 18:53     ` Mirsad Todorovac
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Xu @ 2024-11-01 13:48 UTC (permalink / raw)
  To: Mirsad Todorovac
  Cc: Andrew Morton, Suren Baghdasaryan, linux-mm, linux-kselftest,
	linux-kernel, Shuah Khan, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin

On Fri, Nov 01, 2024 at 12:15:25PM +0100, Mirsad Todorovac wrote:
> Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
> to improve the code readability:
> 
> ./tools/testing/selftests/mm/uffd-unit-tests.c:1484:32-33: WARNING: Use ARRAY_SIZE
> ./tools/testing/selftests/mm/uffd-unit-tests.c:1485:30-31: WARNING: Use ARRAY_SIZE
> 
> Fixes: 16a45b57cbf2 ("selftests/mm: add framework for uffd-unit-test")
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: linux-mm@kvack.org
> Cc: linux-kselftest@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>

Acked-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu



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

* Re: [PATCH v1 2/2] selftests/mm: fix coccinelle WARNING recommending the use of ARRAY_SIZE()
  2024-11-01 13:48   ` Peter Xu
@ 2024-11-02 18:53     ` Mirsad Todorovac
  0 siblings, 0 replies; 6+ messages in thread
From: Mirsad Todorovac @ 2024-11-02 18:53 UTC (permalink / raw)
  To: Peter Xu
  Cc: Andrew Morton, Suren Baghdasaryan, linux-mm, linux-kselftest,
	linux-kernel, Shuah Khan, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin



On 11/1/24 14:48, Peter Xu wrote:
> On Fri, Nov 01, 2024 at 12:15:25PM +0100, Mirsad Todorovac wrote:
>> Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
>> to improve the code readability:
>>
>> ./tools/testing/selftests/mm/uffd-unit-tests.c:1484:32-33: WARNING: Use ARRAY_SIZE
>> ./tools/testing/selftests/mm/uffd-unit-tests.c:1485:30-31: WARNING: Use ARRAY_SIZE
>>
>> Fixes: 16a45b57cbf2 ("selftests/mm: add framework for uffd-unit-test")
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Shuah Khan <shuah@kernel.org>
>> Cc: Peter Xu <peterx@redhat.com>
>> Cc: linux-mm@kvack.org
>> Cc: linux-kselftest@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
> 
> Acked-by: Peter Xu <peterx@redhat.com>

Thanks for the quick review.

Best regards,
Mirsad



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

* Re: [PATCH v1 1/2] selftests/x86/syscall: fix coccinelle WARNING recommending the use of ARRAY_SIZE()
  2024-11-01 12:04 ` [PATCH v1 1/2] selftests/x86/syscall: " Muhammad Usama Anjum
@ 2024-11-02 18:55   ` Mirsad Todorovac
  0 siblings, 0 replies; 6+ messages in thread
From: Mirsad Todorovac @ 2024-11-02 18:55 UTC (permalink / raw)
  To: Muhammad Usama Anjum, Andrew Morton, Suren Baghdasaryan,
	linux-mm, linux-kselftest, linux-kernel
  Cc: Shuah Khan, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin



On 11/1/24 13:04, Muhammad Usama Anjum wrote:
> On 11/1/24 4:15 PM, Mirsad Todorovac wrote:
>> Coccinelle gives WARNING recommending the use of ARRAY_SIZE() macro definition
>> to improve the code readability:
>>
>> ./tools/testing/selftests/x86/syscall_numbering.c:316:35-36: WARNING: Use ARRAY_SIZE
>>
>> Fixes: 15c82d98a0f78 ("selftests/x86/syscall: Update and extend syscall_numbering_64")
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: Borislav Petkov <bp@alien8.de>
>> Cc: Dave Hansen <dave.hansen@linux.intel.com>
>> Cc: x86@kernel.org
>> Cc: "H. Peter Anvin" <hpa@zytor.com>
>> Cc: Shuah Khan <shuah@kernel.org>
>> Cc: linux-kernel@vger.kernel.org
>> Cc: linux-kselftest@vger.kernel.org
>> Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>

> Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

Dear Sir,

Thank you for your positive review of the patch.

There are much more suggestions by the coccinelle check, but that's a substantial work to do.

It would help to set some priorities in this by some more experienced developer.

Thank you.

Best regards,
Mirsad Todorovac
 
>> ---
>>  v1: initial version.
>>
>>  tools/testing/selftests/x86/syscall_numbering.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/x86/syscall_numbering.c b/tools/testing/selftests/x86/syscall_numbering.c
>> index 991591718bb0..41c42b7b54a6 100644
>> --- a/tools/testing/selftests/x86/syscall_numbering.c
>> +++ b/tools/testing/selftests/x86/syscall_numbering.c
>> @@ -25,6 +25,7 @@
>>  #include <sys/mman.h>
>>  
>>  #include <linux/ptrace.h>
>> +#include "../kselftest.h"
>>  
>>  /* Common system call numbers */
>>  #define SYS_READ	  0
>> @@ -313,7 +314,7 @@ static void test_syscall_numbering(void)
>>  	 * The MSB is supposed to be ignored, so we loop over a few
>>  	 * to test that out.
>>  	 */
>> -	for (size_t i = 0; i < sizeof(msbs)/sizeof(msbs[0]); i++) {
>> +	for (size_t i = 0; i < ARRAY_SIZE(msbs); i++) {
>>  		int msb = msbs[i];
>>  		run("Checking system calls with msb = %d (0x%x)\n",
>>  		    msb, msb);
> 


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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-01 11:15 [PATCH v1 1/2] selftests/x86/syscall: fix coccinelle WARNING recommending the use of ARRAY_SIZE() Mirsad Todorovac
2024-11-01 11:15 ` [PATCH v1 2/2] selftests/mm: " Mirsad Todorovac
2024-11-01 13:48   ` Peter Xu
2024-11-02 18:53     ` Mirsad Todorovac
2024-11-01 12:04 ` [PATCH v1 1/2] selftests/x86/syscall: " Muhammad Usama Anjum
2024-11-02 18:55   ` Mirsad Todorovac

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