tree-wide: check if return value of lseek() and friends is negative
We usually check return value of syscalls or glibc functions by it is negative or not, something like that `if (stat(path, &st) < 0)`. Let's also use the same style for lseek() and friends even the type of their return value is off_t. Note, fseeko() returns int, instead of off_t.
This commit is contained in:
@@ -588,7 +588,7 @@ static int parse_core(int fd, const char *executable, char **ret, JsonVariant **
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
return log_warning_errno(errno, "Failed to seek to beginning of the core file: %m");
|
||||
|
||||
if (ret && !memstream_init(&c.m))
|
||||
@@ -644,7 +644,7 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
return log_warning_errno(errno, "Failed to seek to beginning of the ELF file: %m");
|
||||
|
||||
if (ret && !memstream_init(&c.m))
|
||||
|
||||
Reference in New Issue
Block a user