summaryrefslogtreecommitdiffstats
path: root/src/import
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-10-18 06:52:47 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-10-19 11:31:44 +0200
commit86cbbc6d052bc3cc97aa2ece58603a9939f9ee6a (patch)
tree6186d2df19cd787bdc5530462ee063fe8cff8cbc /src/import
parentfuzz: unify logging setup (diff)
downloadsystemd-86cbbc6d052bc3cc97aa2ece58603a9939f9ee6a.tar.xz
systemd-86cbbc6d052bc3cc97aa2ece58603a9939f9ee6a.zip
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.
Diffstat (limited to 'src/import')
-rw-r--r--src/import/import-raw.c4
-rw-r--r--src/import/pull-job.c2
-rw-r--r--src/import/pull-raw.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index feb6ac1bdd..2db3198ba6 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -303,7 +303,7 @@ static int raw_import_open_disk(RawImport *i) {
"Target file is not a regular file or block device");
if (i->offset != UINT64_MAX) {
- if (lseek(i->output_fd, i->offset, SEEK_SET) == (off_t) -1)
+ if (lseek(i->output_fd, i->offset, SEEK_SET) < 0)
return log_error_errno(errno, "Failed to seek to offset: %m");
}
@@ -328,7 +328,7 @@ static int raw_import_try_reflink(RawImport *i) {
return 0;
p = lseek(i->input_fd, 0, SEEK_CUR);
- if (p == (off_t) -1)
+ if (p < 0)
return log_error_errno(errno, "Failed to read file offset of input file: %m");
/* Let's only try a btrfs reflink, if we are reading from the beginning of the file */
diff --git a/src/import/pull-job.c b/src/import/pull-job.c
index d05bf3cd49..bed7e64030 100644
--- a/src/import/pull-job.c
+++ b/src/import/pull-job.c
@@ -415,7 +415,7 @@ static int pull_job_open_disk(PullJob *j) {
return log_error_errno(errno, "Failed to stat disk file: %m");
if (j->offset != UINT64_MAX) {
- if (lseek(j->disk_fd, j->offset, SEEK_SET) == (off_t) -1)
+ if (lseek(j->disk_fd, j->offset, SEEK_SET) < 0)
return log_error_errno(errno, "Failed to seek on file descriptor: %m");
}
}
diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c
index 3befa96a04..e96be4dd7d 100644
--- a/src/import/pull-raw.c
+++ b/src/import/pull-raw.c
@@ -370,7 +370,7 @@ static int raw_pull_make_local_copy(RawPull *i) {
assert(i->raw_job->disk_fd >= 0);
assert(i->offset == UINT64_MAX);
- if (lseek(i->raw_job->disk_fd, SEEK_SET, 0) == (off_t) -1)
+ if (lseek(i->raw_job->disk_fd, SEEK_SET, 0) < 0)
return log_error_errno(errno, "Failed to seek to beginning of vendor image: %m");
}