Hi all, loop_read/write will try to fill/read 'nbytes' of caller supplying buffer. This argument is currently of type size_t, which is always true for loop quit condition "while (nbytes > 0)", hence we change it to type ssize_t here. This also helps to detect passed-in 'nbytes' of value -1 for example.
-- Regards, - cee1
From 54e7ea82ca0051660927d2c4a6c1fdef7fd497a4 Mon Sep 17 00:00:00 2001 From: cee1 <fykc...@gmail.com> Date: Mon, 2 May 2011 10:52:11 +0800 Subject: [PATCH] util: arg 'nbytes' of loop_read/write should be of type ssize_t loop_read/write will try to fill/read 'nbytes' of caller supplying buffer. This argument is currently of type size_t, which is always true for loop quit condition "while (nbytes > 0)", hence we change it to type ssize_t here. This also helps to detect passed-in 'nbytes' of value -1 for example. --- src/util.c | 4 ++-- src/util.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util.c b/src/util.c index f0051ee..252da55 100644 --- a/src/util.c +++ b/src/util.c @@ -2623,7 +2623,7 @@ int close_pipe(int p[]) { return a < 0 ? a : b; } -ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) { +ssize_t loop_read(int fd, void *buf, ssize_t nbytes, bool do_poll) { uint8_t *p; ssize_t n = 0; @@ -2671,7 +2671,7 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) { return n; } -ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) { +ssize_t loop_write(int fd, const void *buf, ssize_t nbytes, bool do_poll) { const uint8_t *p; ssize_t n = 0; diff --git a/src/util.h b/src/util.h index 5f6325b..f0b3d70 100644 --- a/src/util.h +++ b/src/util.h @@ -327,8 +327,8 @@ int sigaction_many(const struct sigaction *sa, ...); int close_pipe(int p[]); -ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll); -ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll); +ssize_t loop_read(int fd, void *buf, ssize_t nbytes, bool do_poll); +ssize_t loop_write(int fd, const void *buf, ssize_t nbytes, bool do_poll); int path_is_mount_point(const char *path); -- 1.7.5.rc1
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel