Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Incorrect format specifiers `%d` used for unsigned `__u32` variables when formatting BTF_KIND_LOC_PARAM and BTF_KIND_LOCSEC. --
commit 775b46a26f73799ae68ad5737114128e343d1d80 Author: Alan Maguire <[email protected]> selftests/bpf: Test helper support for BTF_KIND_LOC[_PARAM|_PROTO|SEC] Add support to dump, encode and validate new location-related kinds. > diff --git a/tools/testing/selftests/bpf/btf_helpers.c > b/tools/testing/selftests/bpf/btf_helpers.c > index 1c1c2c26690a7..6065ee4ba00a6 100644 > --- a/tools/testing/selftests/bpf/btf_helpers.c > +++ b/tools/testing/selftests/bpf/btf_helpers.c [ ... ] > @@ -203,6 +206,37 @@ int fprintf_btf_type_raw(FILE *out, const struct btf > *btf, __u32 id) > fprintf(out, " type_id=%u component_idx=%d", > t->type, btf_decl_tag(t)->component_idx); > break; > + case BTF_KIND_LOC_PARAM: { > + struct btf_loc_param *p = btf_loc_param(t); > + __u32 *v = (__u32 *)(p + 1); > + > + fprintf(out, " size=%d flags=0x%x vlen=%u", t->size, p->flags, > vlen); [Severity: Low] Does this format string interpret the unsigned __u32 t->size as a signed integer? If t->size exceeds 2^31-1, it could be printed as a negative number here, which differs from how other BTF kinds format their sizes using %u. > + for (i = 0; i < vlen; i++, v++) { > + if (p->flags & BTF_LOC_PARAM_SIGNED) > + fprintf(out, "\n\tvalue=%d", (__s32)*v); > + else > + fprintf(out, "\n\tvalue=%u", *v); > + } > + break; > + } [ ... ] > + case BTF_KIND_LOCSEC: { > + const struct btf_loc *l = btf_locsec_locs(t); > + > + fprintf(out, " vlen=%u", vlen); > + for (i = 0; i < vlen; i++, l++) { > + fprintf(out, "\n\tfunc_type_id=%u loc_proto_type_id=%u > offset=%d", > + l->func, l->loc_proto, l->offset); [Severity: Low] Similarly, l->offset is defined as __u32 in struct btf_loc but is formatted with %d. Should this use %u as well to prevent large offsets from appearing negative in the output? > + } > + break; > + } -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=4
