tools/bpftool: Fix uninitialized error
PATCH 1/1 tools/bpftool: Fix uninitialized error
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 <[email protected]>
--- tools/bpf/bpftool/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/bpf/bpftool/main.c +1 -3
@@ -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' ;
Signature · 1 line
2.18.1