lib: bpf_legacy: treat 0 as a valid file descriptor

As stated in the man page(), open returns a non-negative integer as a
file descriptor. Hence, when checking for its return value to be ok, we
should include 0 as a valid value.

This fixes a covscan warning about a missing close() in this function.

Fixes: ecb05c0f99 ("bpf: improve error reporting around tail calls")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Andrea Claudi 2021-04-19 15:49:56 +02:00 committed by Stephen Hemminger
parent 932fe3453f
commit 92af24c907
1 changed files with 1 additions and 1 deletions

View File

@ -2832,7 +2832,7 @@ static void bpf_get_cfg(struct bpf_elf_ctx *ctx)
int fd;
fd = open(path_jit, O_RDONLY);
if (fd > 0) {
if (fd >= 0) {
char tmp[16] = {};
if (read(fd, tmp, sizeof(tmp)) > 0)