* [PATCH linux-next] selftests/vDSO: fix array_size.cocci warning
@ 2022-03-21 5:27 Guo Zhengkui
2022-03-22 23:01 ` Shuah Khan
0 siblings, 1 reply; 2+ messages in thread
From: Guo Zhengkui @ 2022-03-21 5:27 UTC (permalink / raw)
To: Shuah Khan, Guo Zhengkui, linux-kselftest, linux-kernel; +Cc: zhengkui_guo
Fix the following coccicheck warning:
tools/testing/selftests/vDSO/vdso_test_correctness.c:309:46-47:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/vDSO/vdso_test_correctness.c:373:46-47:
WARNING: Use ARRAY_SIZE
It has been tested with gcc (Debian 8.3.0-6) 8.3.0 on x86_64.
Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
tools/testing/selftests/vDSO/vdso_test_correctness.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c
index c4aea794725a..e691a3cf1491 100644
--- a/tools/testing/selftests/vDSO/vdso_test_correctness.c
+++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c
@@ -20,6 +20,7 @@
#include <limits.h>
#include "vdso_config.h"
+#include "../kselftest.h"
static const char **name;
@@ -306,10 +307,8 @@ static void test_clock_gettime(void)
return;
}
- for (int clock = 0; clock < sizeof(clocknames) / sizeof(clocknames[0]);
- clock++) {
+ for (int clock = 0; clock < ARRAY_SIZE(clocknames); clock++)
test_one_clock_gettime(clock, clocknames[clock]);
- }
/* Also test some invalid clock ids */
test_one_clock_gettime(-1, "invalid");
@@ -370,10 +369,8 @@ static void test_clock_gettime64(void)
return;
}
- for (int clock = 0; clock < sizeof(clocknames) / sizeof(clocknames[0]);
- clock++) {
+ for (int clock = 0; clock < ARRAY_SIZE(clocknames); clock++)
test_one_clock_gettime64(clock, clocknames[clock]);
- }
/* Also test some invalid clock ids */
test_one_clock_gettime64(-1, "invalid");
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH linux-next] selftests/vDSO: fix array_size.cocci warning
2022-03-21 5:27 [PATCH linux-next] selftests/vDSO: fix array_size.cocci warning Guo Zhengkui
@ 2022-03-22 23:01 ` Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2022-03-22 23:01 UTC (permalink / raw)
To: Guo Zhengkui, Shuah Khan, linux-kselftest, linux-kernel
Cc: zhengkui_guo, Shuah Khan
On 3/20/22 11:27 PM, Guo Zhengkui wrote:
> Fix the following coccicheck warning:
>
> tools/testing/selftests/vDSO/vdso_test_correctness.c:309:46-47:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/vDSO/vdso_test_correctness.c:373:46-47:
> WARNING: Use ARRAY_SIZE
>
> It has been tested with gcc (Debian 8.3.0-6) 8.3.0 on x86_64.
>
> Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
> ---
> tools/testing/selftests/vDSO/vdso_test_correctness.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c
> index c4aea794725a..e691a3cf1491 100644
> --- a/tools/testing/selftests/vDSO/vdso_test_correctness.c
> +++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c
> @@ -20,6 +20,7 @@
> #include <limits.h>
>
> #include "vdso_config.h"
> +#include "../kselftest.h"
>
> static const char **name;
>
> @@ -306,10 +307,8 @@ static void test_clock_gettime(void)
> return;
> }
>
> - for (int clock = 0; clock < sizeof(clocknames) / sizeof(clocknames[0]);
> - clock++) {
> + for (int clock = 0; clock < ARRAY_SIZE(clocknames); clock++)
> test_one_clock_gettime(clock, clocknames[clock]);
> - }
>
> /* Also test some invalid clock ids */
> test_one_clock_gettime(-1, "invalid");
> @@ -370,10 +369,8 @@ static void test_clock_gettime64(void)
> return;
> }
>
> - for (int clock = 0; clock < sizeof(clocknames) / sizeof(clocknames[0]);
> - clock++) {
> + for (int clock = 0; clock < ARRAY_SIZE(clocknames); clock++)
> test_one_clock_gettime64(clock, clocknames[clock]);
> - }
>
> /* Also test some invalid clock ids */
> test_one_clock_gettime64(-1, "invalid");
>
Looks good to me. I will apply this once merge window closes.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-22 23:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 5:27 [PATCH linux-next] selftests/vDSO: fix array_size.cocci warning Guo Zhengkui
2022-03-22 23:01 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®