diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2019-11-19 11:17:06 +0000 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-11-24 16:58:44 -0800 |
commit | a0f17cc6665c80ab2765f9244c41ec127821f343 (patch) | |
tree | 210d5eafe2c8e36549729e1df540525b390401c9 /tools | |
parent | 5d946c5abbaf68083fa6a41824dd79e1f06286d8 (diff) | |
download | linux-a0f17cc6665c80ab2765f9244c41ec127821f343.tar.bz2 |
tools, bpftool: Fix warning on ignored return value for 'read'
When building bpftool, a warning was introduced by commit a94364603610
("bpftool: Allow to read btf as raw data"), because the return value
from a call to 'read()' is ignored. Let's address it.
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20191119111706.22440-1-quentin.monnet@netronome.com
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bpf/bpftool/btf.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c index a7b8bf233cf5..e5bc97b71ceb 100644 --- a/tools/bpf/bpftool/btf.c +++ b/tools/bpf/bpftool/btf.c @@ -428,15 +428,15 @@ exit_close: static bool is_btf_raw(const char *file) { __u16 magic = 0; - int fd; + int fd, nb_read; fd = open(file, O_RDONLY); if (fd < 0) return false; - read(fd, &magic, sizeof(magic)); + nb_read = read(fd, &magic, sizeof(magic)); close(fd); - return magic == BTF_MAGIC; + return nb_read == sizeof(magic) && magic == BTF_MAGIC; } static int do_dump(int argc, char **argv) |