mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
tree-wide: fix lseek() parameter order
The offset must be specified first, 'whence' second. Fix that. Except for one case this fix doesn't actually fix any real bug, since SEEK_SET is defined as 0 anyway, hence the swapped arguments have no effect. The one exception is the MTD smartmedia code, which I guess indicates that noone has been using that hw anymore in a long time?
This commit is contained in:
@@ -570,7 +570,7 @@ static int home_parse_worker_stdout(int _fd, UserRecord **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lseek(fd, SEEK_SET, 0) < 0)
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
return log_error_errno(errno, "Failed to seek to beginning of memfd: %m");
|
||||
|
||||
f = take_fdopen(&fd, "r");
|
||||
|
||||
@@ -365,7 +365,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) < 0)
|
||||
if (lseek(i->raw_job->disk_fd, 0, SEEK_SET) < 0)
|
||||
return log_error_errno(errno, "Failed to seek to beginning of vendor image: %m");
|
||||
}
|
||||
|
||||
|
||||
@@ -570,8 +570,8 @@ int seat_read_active_vt(Seat *s) {
|
||||
if (!seat_has_vts(s))
|
||||
return 0;
|
||||
|
||||
if (lseek(s->manager->console_active_fd, SEEK_SET, 0) < 0)
|
||||
return log_error_errno(errno, "lseek on console_active_fd failed: %m");
|
||||
if (lseek(s->manager->console_active_fd, 0, SEEK_SET) < 0)
|
||||
return log_error_errno(errno, "lseek() on console_active_fd failed: %m");
|
||||
|
||||
errno = 0;
|
||||
k = read(s->manager->console_active_fd, t, sizeof(t)-1);
|
||||
|
||||
@@ -124,7 +124,7 @@ TEST(copy_file_fd) {
|
||||
assert_se(write_string_file(in_fn, text, WRITE_STRING_FILE_CREATE) == 0);
|
||||
assert_se(copy_file_fd("/a/file/which/does/not/exist/i/guess", out_fd, COPY_REFLINK) < 0);
|
||||
assert_se(copy_file_fd(in_fn, out_fd, COPY_REFLINK) >= 0);
|
||||
assert_se(lseek(out_fd, SEEK_SET, 0) == 0);
|
||||
assert_se(lseek(out_fd, 0, SEEK_SET) == 0);
|
||||
|
||||
assert_se(read(out_fd, buf, sizeof buf) == (ssize_t) strlen(text));
|
||||
ASSERT_STREQ(buf, text);
|
||||
|
||||
@@ -525,7 +525,7 @@ TEST(pid_get_cmdline_harder) {
|
||||
#define EXPECT1p "foo $'\\'bar\\'' $'\"bar$\"' $'x y z' $'!``'"
|
||||
#define EXPECT1v STRV_MAKE("foo", "'bar'", "\"bar$\"", "x y z", "!``")
|
||||
|
||||
ASSERT_OK_ZERO_ERRNO(lseek(fd, SEEK_SET, 0));
|
||||
ASSERT_OK_ZERO_ERRNO(lseek(fd, 0, SEEK_SET));
|
||||
ASSERT_OK_EQ_ERRNO(write(fd, CMDLINE1, sizeof(CMDLINE1)), (ssize_t) sizeof(CMDLINE1));
|
||||
ASSERT_OK_ZERO_ERRNO(ftruncate(fd, sizeof(CMDLINE1)));
|
||||
|
||||
@@ -550,7 +550,7 @@ TEST(pid_get_cmdline_harder) {
|
||||
#define EXPECT2p "foo $'\\001\\002\\003'"
|
||||
#define EXPECT2v STRV_MAKE("foo", "\1\2\3")
|
||||
|
||||
ASSERT_OK_ZERO_ERRNO(lseek(fd, SEEK_SET, 0));
|
||||
ASSERT_OK_ZERO_ERRNO(lseek(fd, 0, SEEK_SET));
|
||||
ASSERT_OK_EQ_ERRNO(write(fd, CMDLINE2, sizeof(CMDLINE2)), (ssize_t) sizeof(CMDLINE2));
|
||||
ASSERT_OK_ZERO_ERRNO(ftruncate(fd, sizeof CMDLINE2));
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ int probe_smart_media(int mtd_fd, mtd_info_t* info) {
|
||||
}
|
||||
|
||||
for (offset = 0; offset < block_size * spare_count; offset += sector_size) {
|
||||
(void) lseek(mtd_fd, SEEK_SET, offset);
|
||||
(void) lseek(mtd_fd, offset, SEEK_SET);
|
||||
|
||||
if (read(mtd_fd, cis_buffer, SM_SECTOR_SIZE) == SM_SECTOR_SIZE) {
|
||||
cis_found = 1;
|
||||
|
||||
Reference in New Issue
Block a user