Messages in this thread Patch in this message | | | From | Matthew Kenigsberg <> | Subject | [PATCH] tools/bpftool: Fix uninitialized error | Date | Thu, 13 Aug 2020 16:24:31 -0600 |
| |
Static analyzer showed following the code path at tools/bpf/bpftool/main.c:308 leads to returning err when uninitialized if (n_argc < 0) goto err_close;
Initializing err to -1 fixes the uninitialized return and prevents having to add a 3rd err = -1 line.
Signed-off-by: Matthew Kenigsberg <mkenigs@redhat.com> --- tools/bpf/bpftool/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 4a191fcbeb82..a60164fe2b72 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -245,7 +245,7 @@ static int do_batch(int argc, char **argv) int n_argc; FILE *fp; char *cp; - int err; + int err = -1; int i; if (argc < 2) { @@ -289,7 +289,6 @@ static int do_batch(int argc, char **argv) strlen(contline) == 0) { p_err("missing continuation line on command %d", lines); - err = -1; goto err_close; } @@ -299,7 +298,6 @@ static int do_batch(int argc, char **argv) if (strlen(buf) + strlen(contline) + 1 > sizeof(buf)) { p_err("command %d is too long", lines); - err = -1; goto err_close; } buf[strlen(buf) - 2] = '\0'; -- 2.18.1
| |