]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/bpf/bpftool/btf.c
tools, bpftool: Fix warning on ignored return value for 'read'
[linux.git] / tools / bpf / bpftool / btf.c
index a7b8bf233cf5756e79c22a00ad33f4f281ff25dc..e5bc97b71ceb67bb5e714be2750bb45baf82ed18 100644 (file)
@@ -428,15 +428,15 @@ static struct btf *btf__parse_raw(const char *file)
 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)