mirror of
https://github.com/systemd/systemd
synced 2024-09-30 05:15:19 +00:00
tree-wide: fix type of read() return variable at a couple of places
read() returns ssize_t (i.e. 64bit typically). We assigned it to int variables in some cases (i.e. 32bit typically). Let's not be so sloppy, and not accidentally drop 32bit on the floor. (of course, this is not an issue IRL since we'll not have allocations above 2^32 ever we could read into, but still, let's clean this up)
This commit is contained in:
parent
57b41f15e5
commit
18eaff4272
|
@ -791,7 +791,8 @@ int parse_elf_object(int fd, const char *executable, bool fork_disable_dump, cha
|
|||
NULL);
|
||||
if (r < 0) {
|
||||
if (r == -EPROTO) { /* We should have the errno from the child, but don't clobber original error */
|
||||
int e, k;
|
||||
ssize_t k;
|
||||
int e;
|
||||
|
||||
k = read(error_pipe[0], &e, sizeof(e));
|
||||
if (k < 0 && errno != EAGAIN) /* Pipe is non-blocking, EAGAIN means there's nothing */
|
||||
|
|
|
@ -127,7 +127,7 @@ static int fill_fixed_size(JournalImporter *imp, void **data, size_t size) {
|
|||
assert(data);
|
||||
|
||||
while (imp->filled - imp->offset < size) {
|
||||
int n;
|
||||
ssize_t n;
|
||||
|
||||
if (imp->passive_fd)
|
||||
/* we have to wait for some data to come to us */
|
||||
|
|
|
@ -293,7 +293,7 @@ TEST(copy_tree_at_symlink) {
|
|||
TEST_RET(copy_bytes) {
|
||||
_cleanup_close_pair_ int pipefd[2] = EBADF_PAIR;
|
||||
_cleanup_close_ int infd = -EBADF;
|
||||
int r, r2;
|
||||
int r;
|
||||
char buf[1024], buf2[1024];
|
||||
|
||||
infd = open("/usr/lib/os-release", O_RDONLY|O_CLOEXEC);
|
||||
|
@ -307,14 +307,14 @@ TEST_RET(copy_bytes) {
|
|||
r = copy_bytes(infd, pipefd[1], UINT64_MAX, 0);
|
||||
assert_se(r == 0);
|
||||
|
||||
r = read(pipefd[0], buf, sizeof(buf));
|
||||
assert_se(r >= 0);
|
||||
ssize_t n = read(pipefd[0], buf, sizeof(buf));
|
||||
assert_se(n >= 0);
|
||||
|
||||
assert_se(lseek(infd, 0, SEEK_SET) == 0);
|
||||
r2 = read(infd, buf2, sizeof(buf2));
|
||||
assert_se(r == r2);
|
||||
ssize_t n2 = read(infd, buf2, sizeof(buf2));
|
||||
assert_se(n == n2);
|
||||
|
||||
assert_se(strneq(buf, buf2, r));
|
||||
assert_se(strneq(buf, buf2, n));
|
||||
|
||||
/* test copy_bytes with invalid descriptors */
|
||||
r = copy_bytes(pipefd[0], pipefd[0], 1, 0);
|
||||
|
|
|
@ -253,9 +253,9 @@ TEST(passfd_read) {
|
|||
assert_se(receive_one_fd_iov(pair[0], &iov, 1, MSG_DONTWAIT, &fd) == 0);
|
||||
|
||||
assert_se(fd >= 0);
|
||||
r = read(fd, buf, sizeof(buf)-1);
|
||||
assert_se(r >= 0);
|
||||
buf[r] = 0;
|
||||
ssize_t n = read(fd, buf, sizeof(buf)-1);
|
||||
assert_se(n >= 0);
|
||||
buf[n] = 0;
|
||||
ASSERT_STREQ(buf, file_contents);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue