diff mbox series

[v2] selftests/x86/syscall: use ARRAY_SIZE for msbs

Message ID 1623406714-52873-1-git-send-email-jiapeng.chong@linux.alibaba.com (mailing list archive)
State Rejected
Headers show
Series [v2] selftests/x86/syscall: use ARRAY_SIZE for msbs | expand

Commit Message

Jiapeng Chong June 11, 2021, 10:18 a.m. UTC
Use ARRAY_SIZE instead of dividing sizeof array with sizeof an
element.

Clean up the following coccicheck warning:

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

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
Changes in v2:
  -Add ARRAY_SIZE definition.

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

Comments

Greg KH June 11, 2021, 10:40 a.m. UTC | #1
On Fri, Jun 11, 2021 at 06:18:34PM +0800, Jiapeng Chong wrote:
> Use ARRAY_SIZE instead of dividing sizeof array with sizeof an
> element.
> 
> Clean up the following coccicheck warning:
> 
> ./tools/testing/selftests/x86/syscall_numbering.c:316:35-36: WARNING:
> Use ARRAY_SIZE.

Same comments apply here as on your usbip tool patch :(
diff mbox series

Patch

diff --git a/tools/testing/selftests/x86/syscall_numbering.c b/tools/testing/selftests/x86/syscall_numbering.c
index 9915917..ef30218 100644
--- a/tools/testing/selftests/x86/syscall_numbering.c
+++ b/tools/testing/selftests/x86/syscall_numbering.c
@@ -40,6 +40,7 @@ 
 #define X32_WRITEV	516
 
 #define X32_BIT 0x40000000
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 static int nullfd = -1;		/* File descriptor for /dev/null */
 static bool with_x32;		/* x32 supported on this kernel? */
@@ -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);