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

Jiri Olsa
2019-10-21T13:55:15Z

On Fri, Oct 18, 2019 at 08:04:44PM +0000, Yonghong Song wrote:

SNIP

> >> + FILE *f;
> >> +
> >> + if (stat(file, &st))
> >> + return btf;
> >> +
> >> + f = fopen(file, "rb");
> >> + if (!f)
> >> + return btf;
> >> +
> >> + buf = malloc(st.st_size);
> >> + if (!buf)
> >> + goto err;
> >> +
> >> + if ((size_t) st.st_size != fread(buf, 1, st.st_size, f))
> >> + goto err;
> >> +
> >> + btf = btf__new(buf, st.st_size);
> >> +
> >> +err:
>
> Non error case can also reach here. Let us change
> label to a different name, e.g., "done"?

ok, will change

thanks,
jirka