tools, bpftool: Avoid array index warnings.
Subsystems (4)
PATCH 1/2 tools, bpftool: Avoid array index warnings.
The bpf_caps array is shorter without CAP_BPF, avoid out of bounds reads if this isn't defined. Working around this avoids -Wno-array-bounds with clang.
--- tools/bpf/bpftool/feature.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/bpf/bpftool/feature.c +6 -1
@@ -843,9 +843,14 @@ static int handle_perms(void)else p_err ("missing %s%s%s%s%s%s%s%srequired for full feature probing; run as root or use 'unprivileged'" ,capability_msg (bpf_caps,0 ), +#ifdef CAP_BPFcapability_msg (bpf_caps,1 ),capability_msg (bpf_caps,2 ), -capability_msg (bpf_caps,3 )); + capability_msg(bpf_caps, 3) +#else +"" ,"" ,"" ,"" ,"" ,"" +#endif /* CAP_BPF */ + ); goto exit_free; }
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH 2/2 tools, bpftool: Remove two unused variables.
Avoid an unused variable warning.
--- tools/bpf/bpftool/skeleton/profiler.bpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/bpf/bpftool/skeleton/profiler.bpf.c +2 -2
@@ -70,7 +70,7 @@ int BPF_PROG(fentry_XXX)static inline void fexit_update_maps (u32 id,struct bpf_perf_event_value *after) { -struct bpf_perf_event_value *before, diff, *accum; +struct bpf_perf_event_value *before, diff; before =bpf_map_lookup_elem (&fentry_readings, &id);/* only account samples with a valid fentry_reading */
@@ -95,7 +95,7 @@ int BPF_PROG(fexit_XXX) {struct bpf_perf_event_value readings[MAX_NUM_MATRICS ];u32 cpu =bpf_get_smp_processor_id (); -u32 i, one =1 , zero =0 ; +u32 i, zero =0 ;int err;u64 *count;
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
Re: [PATCH 2/2] tools, bpftool: Remove two unused variables.
Quoted 5 lines · Ian Rogers
Avoid an unused variable warning.
Signed-off-by Ian Rogers <[email protected]>---
Quoted 28 lines
tools/bpf/bpftool/skeleton/profiler.bpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/bpf/bpftool/skeleton/profiler.bpf.c +2
-3@@ -70,7 +70,7 @@ int BPF_PROG(fentry_XXX)static inline void fexit_update_maps (u32 id,struct bpf_perf_event_value *after) { -struct bpf_perf_event_value *before, diff, *accum; +struct bpf_perf_event_value *before, diff; before =bpf_map_lookup_elem (&fentry_readings, &id);/* only account samples with a valid fentry_reading */ @@ -95,7 +95,7 @@ int BPF_PROG(fexit_XXX) {struct bpf_perf_event_value readings[MAX_NUM_MATRICS ];u32 cpu =bpf_get_smp_processor_id (); -u32 i, one =1 , zero =0 ; +u32 i, zero =0 ;int err;u64 *count; --2.29.0.rc2.309.g374f81d7ae-goog
Re: [PATCH 2/2] tools, bpftool: Remove two unused variables.
In reply to Ian RogersQuoted 3 lines · Ian Rogers
Avoid an unused variable warning.
Signed-off-by Ian Rogers <[email protected]>
Quoted 7 lines · Ian Rogers
The
bpf_capsarray is shorter withoutCAP_BPF, avoid out of bounds reads if this isn't defined. Working around this avoids -Wno-array-bounds with clang.Signed-off-by Ian Rogers <[email protected]>---
Quoted 26 lines
tools/bpf/bpftool/feature.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/bpf/bpftool/feature.c +6
-2@@ -843,9 +843,14 @@ static int handle_perms(void)else p_err ("missing %s%s%s%s%s%s%s%srequired for full feature probing; run as root or use 'unprivileged'" ,capability_msg (bpf_caps,0 ), +#ifdef CAP_BPFcapability_msg (bpf_caps,1 ),capability_msg (bpf_caps,2 ), -capability_msg (bpf_caps,3 )); + capability_msg(bpf_caps, 3) +#else +"" ,"" ,"" ,"" ,"" ,"" +#endif /* CAP_BPF */ + ); goto exit_free; } --2.29.0.rc2.309.g374f81d7ae-goog
Quoted 5 lines · Ian Rogers
The
bpf_capsarray is shorter withoutCAP_BPF, avoid out of bounds reads if this isn't defined. Working around this avoids -Wno-array-bounds with clang.Signed-off-by Ian Rogers <[email protected]>