* [PATCH] selftests: net: fix array_size.cocci warning
@ 2022-03-05 16:18 Guo Zhengkui
2022-03-07 12:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 5+ messages in thread
From: Guo Zhengkui @ 2022-03-05 16:18 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Shuah Khan, Alexei Starovoitov,
Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, netdev, linux-kselftest,
bpf, linux-kernel
Cc: Guo Zhengkui
Fit the following coccicheck warning:
tools/testing/selftests/net/reuseport_bpf_numa.c:89:28-29:
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/net/reuseport_bpf_numa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/reuseport_bpf_numa.c b/tools/testing/selftests/net/reuseport_bpf_numa.c
index b2eebf669b8c..c9ba36aa688e 100644
--- a/tools/testing/selftests/net/reuseport_bpf_numa.c
+++ b/tools/testing/selftests/net/reuseport_bpf_numa.c
@@ -86,7 +86,7 @@ static void attach_bpf(int fd)
memset(&attr, 0, sizeof(attr));
attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER;
- attr.insn_cnt = sizeof(prog) / sizeof(prog[0]);
+ attr.insn_cnt = ARRAY_SIZE(prog);
attr.insns = (unsigned long) &prog;
attr.license = (unsigned long) &bpf_license;
attr.log_buf = (unsigned long) &bpf_log_buf;
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] selftests: net: fix array_size.cocci warning
2022-03-05 16:18 [PATCH] selftests: net: fix array_size.cocci warning Guo Zhengkui
@ 2022-03-07 12:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-07 12:30 UTC (permalink / raw)
To: Guo Zhengkui
Cc: davem, kuba, shuah, ast, daniel, andrii, kafai, songliubraving,
yhs, john.fastabend, kpsingh, netdev, linux-kselftest, bpf,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Sun, 6 Mar 2022 00:18:35 +0800 you wrote:
> Fit the following coccicheck warning:
> tools/testing/selftests/net/reuseport_bpf_numa.c:89:28-29:
> 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>
>
> [...]
Here is the summary with links:
- selftests: net: fix array_size.cocci warning
https://git.kernel.org/netdev/net-next/c/0273d10182ec
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] selftests: net: fix array_size.cocci warning
2022-03-16 9:28 Guo Zhengkui
2022-03-17 14:40 ` patchwork-bot+netdevbpf
@ 2022-03-17 15:22 ` Paolo Abeni
1 sibling, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2022-03-17 15:22 UTC (permalink / raw)
To: Guo Zhengkui, David S. Miller, Jakub Kicinski, Shuah Khan,
Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, open list:NETWORKING [GENERAL],
open list:KERNEL SELFTEST FRAMEWORK, open list,
open list:BPF (Safe dynamic programs and tools)
Cc: zhengkui_guo
On Wed, 2022-03-16 at 17:28 +0800, Guo Zhengkui wrote:
> Fix array_size.cocci warning in tools/testing/selftests/net.
>
> Use `ARRAY_SIZE(arr)` instead of forms like `sizeof(arr)/sizeof(arr[0])`.
>
> It has been tested with gcc (Debian 8.3.0-6) 8.3.0.
>
> Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
This landed to net-next. Next time please specify a target tree in the
patch subj, thanks!
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] selftests: net: fix array_size.cocci warning
2022-03-16 9:28 Guo Zhengkui
@ 2022-03-17 14:40 ` patchwork-bot+netdevbpf
2022-03-17 15:22 ` Paolo Abeni
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-17 14:40 UTC (permalink / raw)
To: Guo Zhengkui
Cc: davem, kuba, shuah, ast, daniel, andrii, kafai, songliubraving,
yhs, john.fastabend, kpsingh, netdev, linux-kselftest,
linux-kernel, bpf, zhengkui_guo
Hello:
This patch was applied to netdev/net-next.git (master)
by Paolo Abeni <pabeni@redhat.com>:
On Wed, 16 Mar 2022 17:28:57 +0800 you wrote:
> Fix array_size.cocci warning in tools/testing/selftests/net.
>
> Use `ARRAY_SIZE(arr)` instead of forms like `sizeof(arr)/sizeof(arr[0])`.
>
> It has been tested with gcc (Debian 8.3.0-6) 8.3.0.
>
> Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
>
> [...]
Here is the summary with links:
- selftests: net: fix array_size.cocci warning
https://git.kernel.org/netdev/net-next/c/1abea24af42c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] selftests: net: fix array_size.cocci warning
@ 2022-03-16 9:28 Guo Zhengkui
2022-03-17 14:40 ` patchwork-bot+netdevbpf
2022-03-17 15:22 ` Paolo Abeni
0 siblings, 2 replies; 5+ messages in thread
From: Guo Zhengkui @ 2022-03-16 9:28 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Shuah Khan, Alexei Starovoitov,
Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh,
open list:NETWORKING [GENERAL],
open list:KERNEL SELFTEST FRAMEWORK, open list,
open list:BPF (Safe dynamic programs and tools)
Cc: zhengkui_guo, Guo Zhengkui
Fix array_size.cocci warning in tools/testing/selftests/net.
Use `ARRAY_SIZE(arr)` instead of forms like `sizeof(arr)/sizeof(arr[0])`.
It has been tested with gcc (Debian 8.3.0-6) 8.3.0.
Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
tools/testing/selftests/net/cmsg_sender.c | 4 +++-
tools/testing/selftests/net/psock_fanout.c | 5 +++--
tools/testing/selftests/net/toeplitz.c | 6 ++++--
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/net/cmsg_sender.c b/tools/testing/selftests/net/cmsg_sender.c
index aed7845c08a8..bc2162909a1a 100644
--- a/tools/testing/selftests/net/cmsg_sender.c
+++ b/tools/testing/selftests/net/cmsg_sender.c
@@ -16,6 +16,8 @@
#include <linux/udp.h>
#include <sys/socket.h>
+#include "../kselftest.h"
+
enum {
ERN_SUCCESS = 0,
/* Well defined errors, callers may depend on these */
@@ -318,7 +320,7 @@ static const char *cs_ts_info2str(unsigned int info)
[SCM_TSTAMP_ACK] = "ACK",
};
- if (info < sizeof(names) / sizeof(names[0]))
+ if (info < ARRAY_SIZE(names))
return names[info];
return "unknown";
}
diff --git a/tools/testing/selftests/net/psock_fanout.c b/tools/testing/selftests/net/psock_fanout.c
index 3653d6468c67..1a736f700be4 100644
--- a/tools/testing/selftests/net/psock_fanout.c
+++ b/tools/testing/selftests/net/psock_fanout.c
@@ -53,6 +53,7 @@
#include <unistd.h>
#include "psock_lib.h"
+#include "../kselftest.h"
#define RING_NUM_FRAMES 20
@@ -117,7 +118,7 @@ static void sock_fanout_set_cbpf(int fd)
struct sock_fprog bpf_prog;
bpf_prog.filter = bpf_filter;
- bpf_prog.len = sizeof(bpf_filter) / sizeof(struct sock_filter);
+ bpf_prog.len = ARRAY_SIZE(bpf_filter);
if (setsockopt(fd, SOL_PACKET, PACKET_FANOUT_DATA, &bpf_prog,
sizeof(bpf_prog))) {
@@ -162,7 +163,7 @@ static void sock_fanout_set_ebpf(int fd)
memset(&attr, 0, sizeof(attr));
attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER;
attr.insns = (unsigned long) prog;
- attr.insn_cnt = sizeof(prog) / sizeof(prog[0]);
+ attr.insn_cnt = ARRAY_SIZE(prog);
attr.license = (unsigned long) "GPL";
attr.log_buf = (unsigned long) log_buf,
attr.log_size = sizeof(log_buf),
diff --git a/tools/testing/selftests/net/toeplitz.c b/tools/testing/selftests/net/toeplitz.c
index c5489341cfb8..90026a27eac0 100644
--- a/tools/testing/selftests/net/toeplitz.c
+++ b/tools/testing/selftests/net/toeplitz.c
@@ -52,6 +52,8 @@
#include <sys/types.h>
#include <unistd.h>
+#include "../kselftest.h"
+
#define TOEPLITZ_KEY_MIN_LEN 40
#define TOEPLITZ_KEY_MAX_LEN 60
@@ -295,7 +297,7 @@ static void __set_filter(int fd, int off_proto, uint8_t proto, int off_dport)
struct sock_fprog prog = {};
prog.filter = filter;
- prog.len = sizeof(filter) / sizeof(struct sock_filter);
+ prog.len = ARRAY_SIZE(filter);
if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &prog, sizeof(prog)))
error(1, errno, "setsockopt filter");
}
@@ -324,7 +326,7 @@ static void set_filter_null(int fd)
struct sock_fprog prog = {};
prog.filter = filter;
- prog.len = sizeof(filter) / sizeof(struct sock_filter);
+ prog.len = ARRAY_SIZE(filter);
if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &prog, sizeof(prog)))
error(1, errno, "setsockopt filter");
}
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-17 15:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-05 16:18 [PATCH] selftests: net: fix array_size.cocci warning Guo Zhengkui
2022-03-07 12:30 ` patchwork-bot+netdevbpf
2022-03-16 9:28 Guo Zhengkui
2022-03-17 14:40 ` patchwork-bot+netdevbpf
2022-03-17 15:22 ` Paolo Abeni
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).