Re: [PATCH bpf-next] tools: bpftool: do not pass json_wtr to emit_obj_refs_json()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 23, 2020 at 8:54 AM Quentin Monnet <quentin@xxxxxxxxxxxxx> wrote:
>
> Building bpftool yields the following complaint:
>
>     pids.c: In function ‘emit_obj_refs_json’:
>     pids.c:175:80: warning: declaration of ‘json_wtr’ shadows a global declaration [-Wshadow]
>       175 | void emit_obj_refs_json(struct obj_refs_table *table, __u32 id, json_writer_t *json_wtr)
>           |                                                                 ~~~~~~~~~~~~~~~^~~~~~~~
>     In file included from pids.c:11:
>     main.h:141:23: note: shadowed declaration is here
>       141 | extern json_writer_t *json_wtr;
>           |                       ^~~~~~~~
>
> json_wtr being exposed in main.h (included in pids.c) as an extern, it
> is directly available and there is no need to pass it through the
> function. Let's simply use the global variable.

I don't think it's a good approach to assume that emit_obj_refs_json
is always going to be using a global json writer. I think this shadow
warning is bogus in this case, honestly. But if it bothers you, let's
just rename json_wtr into whatever other name of argument you prefer.

>
> Signed-off-by: Quentin Monnet <quentin@xxxxxxxxxxxxx>
> ---
>  tools/bpf/bpftool/btf.c  | 2 +-
>  tools/bpf/bpftool/link.c | 2 +-
>  tools/bpf/bpftool/main.h | 3 +--
>  tools/bpf/bpftool/map.c  | 2 +-
>  tools/bpf/bpftool/pids.c | 2 +-
>  tools/bpf/bpftool/prog.c | 2 +-
>  6 files changed, 6 insertions(+), 7 deletions(-)
>

[...]




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux