Skip to content

Commit

Permalink
libbpf: Fix build by renaming variables
Browse files Browse the repository at this point in the history
In btf__align_of() variable name 't' is shadowed by inner block
declaration of another variable with same name. Patch renames
variables in order to fix it.

  CC       sharedobjs/btf.o
btf.c: In function ‘btf__align_of’:
btf.c:303:21: error: declaration of ‘t’ shadows a previous local [-Werror=shadow]
  303 |   int i, align = 1, t;
      |                     ^
btf.c:283:25: note: shadowed declaration is here
  283 |  const struct btf_type *t = btf__type_by_id(btf, id);
      |

Fixes: 3d208f4 ("libbpf: Expose btf__align_of() API")
Signed-off-by: Prashant Bhole <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Tested-by: Toke Høiland-Jørgensen <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
pbhole authored and borkmann committed Dec 16, 2019
1 parent 0849e10 commit a79ac2d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/lib/bpf/btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,16 @@ int btf__align_of(const struct btf *btf, __u32 id)
case BTF_KIND_UNION: {
const struct btf_member *m = btf_members(t);
__u16 vlen = btf_vlen(t);
int i, align = 1, t;
int i, max_align = 1, align;

for (i = 0; i < vlen; i++, m++) {
t = btf__align_of(btf, m->type);
if (t <= 0)
return t;
align = max(align, t);
align = btf__align_of(btf, m->type);
if (align <= 0)
return align;
max_align = max(max_align, align);
}

return align;
return max_align;
}
default:
pr_warn("unsupported BTF_KIND:%u\n", btf_kind(t));
Expand Down

0 comments on commit a79ac2d

Please sign in to comment.