]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf bpf: Fix up build failure due to change of btf_vlen() return type
authorMark Brown <broonie@kernel.org>
Wed, 17 Jun 2026 13:00:38 +0000 (14:00 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 22 Jun 2026 18:53:34 +0000 (15:53 -0300)
Fix:

util/btf.c: In function '__btf_type__find_member_by_name':
util/btf.c:19:43: error: comparison of integer expressions of different signedness: 'int' and '__u32' {aka 'unsigned int'} [-Werror=sign-compare]
   19 |         for (i = 0, m = btf_members(t); i < btf_vlen(t); i++, m++) {
      |                                           ^

builtin-trace.c: In function 'syscall_arg__strtoul_btf_enum':
builtin-trace.c:967:27: error: comparison of integer expressions of different signedness: 'int' and '__u32' {aka 'unsigned int'} [-Werror=sign-compare]
  967 |         for (int i = 0; i < btf_vlen(bt); ++i, ++be) {
      |                           ^

by making the variable the same type as the function.

Committer note:

Add an extra hunk from Alan Maguire, fixing btf_enum_scnprintf().

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c
tools/perf/util/btf.c

index 57f3f14c5d435805c0973853316eb503edf1c85f..ba0f8749fc7d7969eb58462580958a9dd9b01df6 100644 (file)
@@ -972,7 +972,7 @@ static bool syscall_arg__strtoul_btf_enum(char *bf, size_t size, struct syscall_
        struct btf *btf = arg->trace->btf;
        struct btf_enum *be = btf_enum(bt);
 
-       for (int i = 0; i < btf_vlen(bt); ++i, ++be) {
+       for (u32 i = 0; i < btf_vlen(bt); ++i, ++be) {
                const char *name = btf__name_by_offset(btf, be->name_off);
                int max_len = max(size, strlen(name));
 
@@ -1017,9 +1017,9 @@ static bool syscall_arg__strtoul_btf_type(char *bf, size_t size, struct syscall_
 static size_t btf_enum_scnprintf(const struct btf_type *type, struct btf *btf, char *bf, size_t size, int val)
 {
        struct btf_enum *be = btf_enum(type);
-       const int nr_entries = btf_vlen(type);
+       const unsigned int nr_entries = btf_vlen(type);
 
-       for (int i = 0; i < nr_entries; ++i, ++be) {
+       for (unsigned int i = 0; i < nr_entries; ++i, ++be) {
                if (be->val == val) {
                        return scnprintf(bf, size, "%s",
                                         btf__name_by_offset(btf, be->name_off));
index bb163fe87767cfdda3efc2029a05d12c46db69f7..50d98f3e83bf018bfc69ec2c1e65607dfc2d6b7f 100644 (file)
@@ -14,7 +14,7 @@ const struct btf_member *__btf_type__find_member_by_name(struct btf *btf,
 {
        const struct btf_type *t = btf__type_by_id(btf, type_id);
        const struct btf_member *m;
-       int i;
+       u32 i;
 
        for (i = 0, m = btf_members(t); i < btf_vlen(t); i++, m++) {
                const char *current_member_name = btf__name_by_offset(btf, m->name_off);