selftests/bpf: Fix incorrect array size calculation
Subsystems (3)
PATCH 1/1 selftests/bpf: Fix incorrect array size calculation
Fix it by using ARRAY_SIZE.
Signed-off-by Jiayuan Chen <[email protected]>
Reported-by Dan Carpenter <[email protected]>
--- tools/testing/selftests/bpf/benchs/bench_sockmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/benchs/bench_sockmap.c +3 -2
@@ -10,6 +10,7 @@#include <argp.h> #include "bench.h" #include "bench_sockmap_prog.skel.h" +#include "bpf_util.h" #define FILE_SIZE (128 * 1024)#define DATA_REPEAT_SIZE 10
@@ -124,8 +125,8 @@ static void bench_sockmap_prog_destroy(void) {int i; -for (i =0 ; i <sizeof (ctx.fds); i++) { -if (ctx.fds[0 ] >0 ) +for (i =0 ; i <ARRAY_SIZE (ctx.fds); i++) { +if (ctx.fds[i] >0 )close (ctx.fds[i]); }
base-commit: 60ef54156148ffaa719845bc5b1fdeafa67763fc
Signature · 1 line
2.43.0
Quoted 2 lines · Jiayuan Chen
Fix it by using
ARRAY_SIZE.
Fix what ?
The commit log should be clear on its own and shouldn't require people clicking through the links.
pw-bot: cr