Commit 4bbb3583 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

bpftool: Fix maybe-uninitialized warnings

Somehow when bpftool is compiled in -Og mode, compiler produces new warnings
about possibly uninitialized variables. Fix all the reported problems.

Fixes: 2119f218 ("bpftool: add C output format option to btf dump subcommand")
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210313210920.1959628-3-andrii@kernel.org
parent dde7b3f5
...@@ -546,6 +546,7 @@ static int do_dump(int argc, char **argv) ...@@ -546,6 +546,7 @@ static int do_dump(int argc, char **argv)
NEXT_ARG(); NEXT_ARG();
if (argc < 1) { if (argc < 1) {
p_err("expecting value for 'format' option\n"); p_err("expecting value for 'format' option\n");
err = -EINVAL;
goto done; goto done;
} }
if (strcmp(*argv, "c") == 0) { if (strcmp(*argv, "c") == 0) {
...@@ -555,11 +556,13 @@ static int do_dump(int argc, char **argv) ...@@ -555,11 +556,13 @@ static int do_dump(int argc, char **argv)
} else { } else {
p_err("unrecognized format specifier: '%s', possible values: raw, c", p_err("unrecognized format specifier: '%s', possible values: raw, c",
*argv); *argv);
err = -EINVAL;
goto done; goto done;
} }
NEXT_ARG(); NEXT_ARG();
} else { } else {
p_err("unrecognized option: '%s'", *argv); p_err("unrecognized option: '%s'", *argv);
err = -EINVAL;
goto done; goto done;
} }
} }
......
...@@ -276,7 +276,7 @@ static int do_batch(int argc, char **argv) ...@@ -276,7 +276,7 @@ static int do_batch(int argc, char **argv)
int n_argc; int n_argc;
FILE *fp; FILE *fp;
char *cp; char *cp;
int err; int err = 0;
int i; int i;
if (argc < 2) { if (argc < 2) {
...@@ -370,7 +370,6 @@ static int do_batch(int argc, char **argv) ...@@ -370,7 +370,6 @@ static int do_batch(int argc, char **argv)
} else { } else {
if (!json_output) if (!json_output)
printf("processed %d commands\n", lines); printf("processed %d commands\n", lines);
err = 0;
} }
err_close: err_close:
if (fp != stdin) if (fp != stdin)
......
...@@ -100,7 +100,7 @@ static int do_dump_btf(const struct btf_dumper *d, ...@@ -100,7 +100,7 @@ static int do_dump_btf(const struct btf_dumper *d,
void *value) void *value)
{ {
__u32 value_id; __u32 value_id;
int ret; int ret = 0;
/* start of key-value pair */ /* start of key-value pair */
jsonw_start_object(d->jw); jsonw_start_object(d->jw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment