From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: alexei.starovoitov@gmail.com, daniel@iogearbox.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
Jiong Wang <jiong.wang@netronome.com>
Subject: [PATCH bpf-next v2 1/8] tools: bpftool: remove unnecessary 'if' to reduce indentation
Date: Thu, 1 Mar 2018 18:01:16 -0800 [thread overview]
Message-ID: <20180302020123.21951-2-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180302020123.21951-1-jakub.kicinski@netronome.com>
From: Jiong Wang <jiong.wang@netronome.com>
It is obvious we could use 'else if' instead of start a new 'if' in the
touched code.
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
tools/bpf/bpftool/prog.c | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index e549e329be82..950d11dd42ab 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -777,27 +777,25 @@ static int do_dump(int argc, char **argv)
if (json_output)
jsonw_null(json_wtr);
- } else {
- if (member_len == &info.jited_prog_len) {
- const char *name = NULL;
-
- if (info.ifindex) {
- name = ifindex_to_bfd_name_ns(info.ifindex,
- info.netns_dev,
- info.netns_ino);
- if (!name)
- goto err_free;
- }
-
- disasm_print_insn(buf, *member_len, opcodes, name);
- } else {
- kernel_syms_load(&dd);
- if (json_output)
- dump_xlated_json(&dd, buf, *member_len, opcodes);
- else
- dump_xlated_plain(&dd, buf, *member_len, opcodes);
- kernel_syms_destroy(&dd);
+ } else if (member_len == &info.jited_prog_len) {
+ const char *name = NULL;
+
+ if (info.ifindex) {
+ name = ifindex_to_bfd_name_ns(info.ifindex,
+ info.netns_dev,
+ info.netns_ino);
+ if (!name)
+ goto err_free;
}
+
+ disasm_print_insn(buf, *member_len, opcodes, name);
+ } else {
+ kernel_syms_load(&dd);
+ if (json_output)
+ dump_xlated_json(&dd, buf, *member_len, opcodes);
+ else
+ dump_xlated_plain(&dd, buf, *member_len, opcodes);
+ kernel_syms_destroy(&dd);
}
free(buf);
--
2.15.1
next prev parent reply other threads:[~2018-03-02 2:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-02 2:01 [PATCH bpf-next v2 0/8] tools: bpftool: visualization support for eBPF program Jakub Kicinski
2018-03-02 2:01 ` Jakub Kicinski [this message]
2018-03-02 2:01 ` [PATCH bpf-next v2 2/8] tools: bpftool: factor out xlated dump related code into separate file Jakub Kicinski
2018-03-02 2:01 ` [PATCH bpf-next v2 3/8] tools: bpftool: detect sub-programs from the eBPF sequence Jakub Kicinski
2018-03-02 2:01 ` [PATCH bpf-next v2 4/8] tools: bpftool: partition basic-block for each function in the CFG Jakub Kicinski
2018-03-02 2:01 ` [PATCH bpf-next v2 5/8] tools: bpftool: add out edges for each basic-block Jakub Kicinski
2018-03-02 2:01 ` [PATCH bpf-next v2 6/8] tools: bpftool: generate .dot graph from CFG information Jakub Kicinski
2018-03-02 2:01 ` [PATCH bpf-next v2 7/8] tools: bpftool: new command-line option and documentation for 'visual' Jakub Kicinski
2018-03-02 2:01 ` [PATCH bpf-next v2 8/8] tools: bpftool: add bash completion for CFG dump Jakub Kicinski
2018-03-02 2:17 ` [PATCH bpf-next v2 0/8] tools: bpftool: visualization support for eBPF program David Miller
2018-03-02 2:51 ` Alexei Starovoitov
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=20180302020123.21951-2-jakub.kicinski@netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=jiong.wang@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
/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;
as well as URLs for NNTP newsgroup(s).