Thread (8 messages) flat view 8 messages, 5 authors, 2019-10-21

Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

From: Jakub Kicinski <hidden>
Date: 2019-10-21 23:16:05
Also in: bpf

On Mon, 21 Oct 2019 16:02:27 +0200, Jiri Olsa wrote:
quoted
quoted
 static int do_dump(int argc, char **argv)
 {
 	struct btf *btf = NULL;
@@ -397,7 +429,7 @@ static int do_dump(int argc, char **argv)
 	__u32 btf_id = -1;
 	const char *src;
 	int fd = -1;
-	int err;
+	int err = 0;  
This change looks unnecessary.  
I'm getting confusing warnings from gcc about this,
but there is a code path where do_dump would return
untouched err:

  do_dump
     int err;

     } else if (is_prefix(src, "file")) {
       btf = btf__parse_elf(*argv, NULL);   // succeeds

     }

     while (argc) {
       if (is_prefix(*argv, "format")) {
       else {                                // in here
          goto done;
       }

     done:
       return err;
ugh, right those look legit, although unrelated to you change.

err should always be set before jumping to 'done'. The error
setting in this function looks super messy :( Sometimes is returns
errno codes, sometimes positive values, sometimes negative, sometimes
just -1. Sometimes it jumps to 'done' for no good reason, ahh :/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help