Skip to content

Commit 3d15bf2

Browse files
anakryikogregkh
authored andcommitted
bpftool: Fix maybe-uninitialized warnings
[ Upstream commit 4bbb358 ] Somehow when bpftool is compiled in -Og mode, compiler produces new warnings about possibly uninitialized variables. Fix all the reported problems. Fixes: 2119f21 ("bpftool: add C output format option to btf dump subcommand") Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20210313210920.1959628-3-andrii@kernel.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b1ed7a5 commit 3d15bf2

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎tools/bpf/bpftool/btf.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ static int do_dump(int argc, char **argv)
519519
NEXT_ARG();
520520
if (argc < 1) {
521521
p_err("expecting value for 'format' option\n");
522+
err = -EINVAL;
522523
goto done;
523524
}
524525
if (strcmp(*argv, "c") == 0) {
@@ -528,11 +529,13 @@ static int do_dump(int argc, char **argv)
528529
} else {
529530
p_err("unrecognized format specifier: '%s', possible values: raw, c",
530531
*argv);
532+
err = -EINVAL;
531533
goto done;
532534
}
533535
NEXT_ARG();
534536
} else {
535537
p_err("unrecognized option: '%s'", *argv);
538+
err = -EINVAL;
536539
goto done;
537540
}
538541
}

‎tools/bpf/bpftool/main.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int do_batch(int argc, char **argv)
274274
int n_argc;
275275
FILE *fp;
276276
char *cp;
277-
int err;
277+
int err = 0;
278278
int i;
279279

280280
if (argc < 2) {
@@ -368,7 +368,6 @@ static int do_batch(int argc, char **argv)
368368
} else {
369369
if (!json_output)
370370
printf("processed %d commands\n", lines);
371-
err = 0;
372371
}
373372
err_close:
374373
if (fp != stdin)

‎tools/bpf/bpftool/map.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int do_dump_btf(const struct btf_dumper *d,
9999
void *value)
100100
{
101101
__u32 value_id;
102-
int ret;
102+
int ret = 0;
103103

104104
/* start of key-value pair */
105105
jsonw_start_object(d->jw);

0 commit comments

Comments
 (0)