All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: fix build by renaming variables
@ 2019-12-16  8:27 Prashant Bhole
  2019-12-16 10:19 ` Toke Høiland-Jørgensen
  2019-12-16 13:25 ` Daniel Borkmann
  0 siblings, 2 replies; 7+ messages in thread
From: Prashant Bhole @ 2019-12-16  8:27 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Andrii Nakryiko, netdev, bpf

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: 3d208f4ca111 ("libbpf: Expose btf__align_of() API")
Signed-off-by: Prashant Bhole <prashantbhole.linux@gmail.com>
---
 tools/lib/bpf/btf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 520021939d81..5f04f56e1eb6 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -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));
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: fix build by renaming variables
  2019-12-16  8:27 [PATCH bpf-next] libbpf: fix build by renaming variables Prashant Bhole
@ 2019-12-16 10:19 ` Toke Høiland-Jørgensen
  2019-12-16 13:25 ` Daniel Borkmann
  1 sibling, 0 replies; 7+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-12-16 10:19 UTC (permalink / raw)
  To: Prashant Bhole, Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Andrii Nakryiko, netdev, bpf

Prashant Bhole <prashantbhole.linux@gmail.com> writes:

> 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: 3d208f4ca111 ("libbpf: Expose btf__align_of() API")
> Signed-off-by: Prashant Bhole <prashantbhole.linux@gmail.com>

Seems there are quite a few build errors in bpf today; this at least
fixes libbpf. Thank you!

Tested-by: Toke Høiland-Jørgensen <toke@redhat.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: fix build by renaming variables
  2019-12-16  8:27 [PATCH bpf-next] libbpf: fix build by renaming variables Prashant Bhole
  2019-12-16 10:19 ` Toke Høiland-Jørgensen
@ 2019-12-16 13:25 ` Daniel Borkmann
  2019-12-16 14:02   ` Alexei Starovoitov
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Borkmann @ 2019-12-16 13:25 UTC (permalink / raw)
  To: Prashant Bhole; +Cc: Alexei Starovoitov, Andrii Nakryiko, netdev, bpf

On Mon, Dec 16, 2019 at 05:27:38PM +0900, Prashant Bhole wrote:
> 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: 3d208f4ca111 ("libbpf: Expose btf__align_of() API")
> Signed-off-by: Prashant Bhole <prashantbhole.linux@gmail.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: fix build by renaming variables
  2019-12-16 13:25 ` Daniel Borkmann
@ 2019-12-16 14:02   ` Alexei Starovoitov
  2019-12-16 14:29     ` Daniel Borkmann
  2019-12-17  0:15     ` Prashant Bhole
  0 siblings, 2 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2019-12-16 14:02 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Prashant Bhole, Alexei Starovoitov, Andrii Nakryiko,
	Network Development, bpf

On Mon, Dec 16, 2019 at 5:25 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On Mon, Dec 16, 2019 at 05:27:38PM +0900, Prashant Bhole wrote:
> > 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: 3d208f4ca111 ("libbpf: Expose btf__align_of() API")
> > Signed-off-by: Prashant Bhole <prashantbhole.linux@gmail.com>
>
> Applied, thanks!

Prashant,
Thanks for the fixes.
Which compiler do use?
Sadly I didn't see any of those with my gcc 6.3.0
Going to upgrade it. Need to decide which one.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: fix build by renaming variables
  2019-12-16 14:02   ` Alexei Starovoitov
@ 2019-12-16 14:29     ` Daniel Borkmann
  2019-12-17  0:15     ` Prashant Bhole
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Borkmann @ 2019-12-16 14:29 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Prashant Bhole, Alexei Starovoitov, Andrii Nakryiko,
	Network Development, bpf

On Mon, Dec 16, 2019 at 06:02:26AM -0800, Alexei Starovoitov wrote:
> On Mon, Dec 16, 2019 at 5:25 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
> > On Mon, Dec 16, 2019 at 05:27:38PM +0900, Prashant Bhole wrote:
> > > 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: 3d208f4ca111 ("libbpf: Expose btf__align_of() API")
> > > Signed-off-by: Prashant Bhole <prashantbhole.linux@gmail.com>
> >
> > Applied, thanks!
> 
> Prashant,
> Thanks for the fixes.
> Which compiler do use?
> Sadly I didn't see any of those with my gcc 6.3.0
> Going to upgrade it. Need to decide which one.

I've seen it with:

$ gcc --version
gcc (GCC) 9.0.1 20190312 (Red Hat 9.0.1-0.10)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: fix build by renaming variables
  2019-12-16 14:02   ` Alexei Starovoitov
  2019-12-16 14:29     ` Daniel Borkmann
@ 2019-12-17  0:15     ` Prashant Bhole
  2019-12-17  2:07       ` Alexei Starovoitov
  1 sibling, 1 reply; 7+ messages in thread
From: Prashant Bhole @ 2019-12-17  0:15 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Alexei Starovoitov, Andrii Nakryiko, Network Development, bpf



On 12/16/19 11:02 PM, Alexei Starovoitov wrote:
> On Mon, Dec 16, 2019 at 5:25 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>>
>> On Mon, Dec 16, 2019 at 05:27:38PM +0900, Prashant Bhole wrote:
>>> 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: 3d208f4ca111 ("libbpf: Expose btf__align_of() API")
>>> Signed-off-by: Prashant Bhole <prashantbhole.linux@gmail.com>
>>
>> Applied, thanks!
> 
> Prashant,
> Thanks for the fixes.
> Which compiler do use?

gcc (GCC) 9.1.1 20190503 (Red Hat 9.1.1-1)

> Sadly I didn't see any of those with my gcc 6.3.0
> Going to upgrade it. Need to decide which one.
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: fix build by renaming variables
  2019-12-17  0:15     ` Prashant Bhole
@ 2019-12-17  2:07       ` Alexei Starovoitov
  0 siblings, 0 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2019-12-17  2:07 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Daniel Borkmann, Alexei Starovoitov, Andrii Nakryiko,
	Network Development, bpf

On Mon, Dec 16, 2019 at 4:17 PM Prashant Bhole
<prashantbhole.linux@gmail.com> wrote:
>
>
>
> On 12/16/19 11:02 PM, Alexei Starovoitov wrote:
> > On Mon, Dec 16, 2019 at 5:25 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
> >>
> >> On Mon, Dec 16, 2019 at 05:27:38PM +0900, Prashant Bhole wrote:
> >>> 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: 3d208f4ca111 ("libbpf: Expose btf__align_of() API")
> >>> Signed-off-by: Prashant Bhole <prashantbhole.linux@gmail.com>
> >>
> >> Applied, thanks!
> >
> > Prashant,
> > Thanks for the fixes.
> > Which compiler do use?
>
> gcc (GCC) 9.1.1 20190503 (Red Hat 9.1.1-1)

I've tried devtoolset-8 and devtoolset-9.
Which is
gcc version 9.1.1 20190605 (Red Hat 9.1.1-2) (GCC)

make clean;make doesn't produce that warning.
make V=1 tells me:
gcc -O2 -W -Wall -Wextra -Wno-unused-parameter
-Wno-missing-field-initializers -Wbad-function-cast
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k
-Winit-self -Wmissing-declarations -Wmissing-prototypes
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wundef
-Wwrite-strings -Wformat -Wstrict-aliasing=3 -fno-strict-aliasing
-Wno-shadow
... -c -MMD -o gen.o gen.c

For some odd reason this check is failing for me
$ tools/scripts/Makefile.include
ifneq ($(filter 3.%,$(MAKE_VERSION)),)  # make-3
EXTRA_WARNINGS += -fno-strict-aliasing
EXTRA_WARNINGS += -Wno-shadow
else
EXTRA_WARNINGS += -Wshadow
endif

$ make -v
GNU Make 3.82

Not sure how to fix this.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-12-17  2:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-16  8:27 [PATCH bpf-next] libbpf: fix build by renaming variables Prashant Bhole
2019-12-16 10:19 ` Toke Høiland-Jørgensen
2019-12-16 13:25 ` Daniel Borkmann
2019-12-16 14:02   ` Alexei Starovoitov
2019-12-16 14:29     ` Daniel Borkmann
2019-12-17  0:15     ` Prashant Bhole
2019-12-17  2:07       ` Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.