From: Quentin Monnet <quentin@isovalent.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: Andrii Nakryiko <andriin@fb.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
Quentin Monnet <quentin@isovalent.com>
Subject: [PATCH bpf-next v2] tools: bpftool: fix variable shadowing in emit_obj_refs_json()
Date: Tue, 23 Jun 2020 22:36:00 +0100 [thread overview]
Message-ID: <20200623213600.16643-1-quentin@isovalent.com> (raw)
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;
| ^~~~~~~~
Let's rename the variable.
v2:
- Rename the variable instead of calling the global json_wtr directly.
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
---
v1 was "tools: bpftool: do not pass json_wtr to emit_obj_refs_json()"
---
tools/bpf/bpftool/pids.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/tools/bpf/bpftool/pids.c b/tools/bpf/bpftool/pids.c
index 3474a91743ff..2709be4de2b1 100644
--- a/tools/bpf/bpftool/pids.c
+++ b/tools/bpf/bpftool/pids.c
@@ -172,7 +172,8 @@ void delete_obj_refs_table(struct obj_refs_table *table)
}
}
-void emit_obj_refs_json(struct obj_refs_table *table, __u32 id, json_writer_t *json_wtr)
+void emit_obj_refs_json(struct obj_refs_table *table, __u32 id,
+ json_writer_t *json_writer)
{
struct obj_refs *refs;
struct obj_ref *ref;
@@ -187,16 +188,16 @@ void emit_obj_refs_json(struct obj_refs_table *table, __u32 id, json_writer_t *j
if (refs->ref_cnt == 0)
break;
- jsonw_name(json_wtr, "pids");
- jsonw_start_array(json_wtr);
+ jsonw_name(json_writer, "pids");
+ jsonw_start_array(json_writer);
for (i = 0; i < refs->ref_cnt; i++) {
ref = &refs->refs[i];
- jsonw_start_object(json_wtr);
- jsonw_int_field(json_wtr, "pid", ref->pid);
- jsonw_string_field(json_wtr, "comm", ref->comm);
- jsonw_end_object(json_wtr);
+ jsonw_start_object(json_writer);
+ jsonw_int_field(json_writer, "pid", ref->pid);
+ jsonw_string_field(json_writer, "comm", ref->comm);
+ jsonw_end_object(json_writer);
}
- jsonw_end_array(json_wtr);
+ jsonw_end_array(json_writer);
break;
}
}
--
2.20.1
next reply other threads:[~2020-06-23 21:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 21:36 Quentin Monnet [this message]
2020-06-23 22:15 ` [PATCH bpf-next v2] tools: bpftool: fix variable shadowing in emit_obj_refs_json() Andrii Nakryiko
2020-06-24 14:18 ` Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200623213600.16643-1-quentin@isovalent.com \
--to=quentin@isovalent.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox