* [PATCH linux-next] selftests/proc: fix array_size.cocci warning
@ 2022-03-21 10:25 Guo Zhengkui
2022-03-22 23:02 ` Shuah Khan
0 siblings, 1 reply; 2+ messages in thread
From: Guo Zhengkui @ 2022-03-21 10:25 UTC (permalink / raw)
To: Shuah Khan, Guo Zhengkui, linux-kernel, linux-fsdevel, linux-kselftest
Cc: zhengkui_guo
Fix the following coccicheck warning:
tools/testing/selftests/proc/proc-pid-vm.c:371:26-27:
WARNING: Use ARRAY_SIZE
tools/testing/selftests/proc/proc-pid-vm.c:420:26-27:
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/proc/proc-pid-vm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
index 18a3bde8bc96..28604c9f805c 100644
--- a/tools/testing/selftests/proc/proc-pid-vm.c
+++ b/tools/testing/selftests/proc/proc-pid-vm.c
@@ -46,6 +46,8 @@
#include <sys/time.h>
#include <sys/resource.h>
+#include "../kselftest.h"
+
static inline long sys_execveat(int dirfd, const char *pathname, char **argv, char **envp, int flags)
{
return syscall(SYS_execveat, dirfd, pathname, argv, envp, flags);
@@ -368,7 +370,7 @@ int main(void)
};
int i;
- for (i = 0; i < sizeof(S)/sizeof(S[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(S); i++) {
assert(memmem(buf, rv, S[i], strlen(S[i])));
}
@@ -417,7 +419,7 @@ int main(void)
};
int i;
- for (i = 0; i < sizeof(S)/sizeof(S[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(S); i++) {
assert(memmem(buf, rv, S[i], strlen(S[i])));
}
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH linux-next] selftests/proc: fix array_size.cocci warning
2022-03-21 10:25 [PATCH linux-next] selftests/proc: fix array_size.cocci warning Guo Zhengkui
@ 2022-03-22 23:02 ` Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2022-03-22 23:02 UTC (permalink / raw)
To: Guo Zhengkui, Shuah Khan, linux-kernel, linux-fsdevel, linux-kselftest
Cc: zhengkui_guo, Shuah Khan
On 3/21/22 4:25 AM, Guo Zhengkui wrote:
> Fix the following coccicheck warning:
>
> tools/testing/selftests/proc/proc-pid-vm.c:371:26-27:
> WARNING: Use ARRAY_SIZE
> tools/testing/selftests/proc/proc-pid-vm.c:420:26-27:
> 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/proc/proc-pid-vm.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
> index 18a3bde8bc96..28604c9f805c 100644
> --- a/tools/testing/selftests/proc/proc-pid-vm.c
> +++ b/tools/testing/selftests/proc/proc-pid-vm.c
> @@ -46,6 +46,8 @@
> #include <sys/time.h>
> #include <sys/resource.h>
>
> +#include "../kselftest.h"
> +
> static inline long sys_execveat(int dirfd, const char *pathname, char **argv, char **envp, int flags)
> {
> return syscall(SYS_execveat, dirfd, pathname, argv, envp, flags);
> @@ -368,7 +370,7 @@ int main(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(S)/sizeof(S[0]); i++) {
> + for (i = 0; i < ARRAY_SIZE(S); i++) {
> assert(memmem(buf, rv, S[i], strlen(S[i])));
> }
>
> @@ -417,7 +419,7 @@ int main(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(S)/sizeof(S[0]); i++) {
> + for (i = 0; i < ARRAY_SIZE(S); i++) {
> assert(memmem(buf, rv, S[i], strlen(S[i])));
> }
> }
>
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:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 10:25 [PATCH linux-next] selftests/proc: fix array_size.cocci warning Guo Zhengkui
2022-03-22 23:02 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).