diff options
author | Guo Zhengkui <guozhengkui@vivo.com> | 2022-03-16 17:28:57 +0800 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2022-03-17 15:21:16 +0100 |
commit | 1abea24af42c35c6eb537e4402836e2cde2a5b13 (patch) | |
tree | 431b689970b3d514588729d863cca40a4d1eaf7a /tools/testing/selftests/net/toeplitz.c | |
parent | 58e06d05d43a9e37e121edabaada00a9d844444c (diff) | |
download | linux-stable-1abea24af42c35c6eb537e4402836e2cde2a5b13.tar.gz linux-stable-1abea24af42c35c6eb537e4402836e2cde2a5b13.tar.bz2 linux-stable-1abea24af42c35c6eb537e4402836e2cde2a5b13.zip |
selftests: net: fix array_size.cocci warning
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>
Link: https://lore.kernel.org/r/20220316092858.9398-1-guozhengkui@vivo.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'tools/testing/selftests/net/toeplitz.c')
-rw-r--r-- | tools/testing/selftests/net/toeplitz.c | 6 |
1 files changed, 4 insertions, 2 deletions
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"); } |