From: Martin Schwenke Date: Sun, 22 Sep 2024 06:37:50 +0000 (+1000) Subject: util: Avoid signed/unsigned integer comparisons X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59ef918c03f78f8ef2a19c504fd40f7e7368e905;p=thirdparty%2Fsamba.git util: Avoid signed/unsigned integer comparisons ../../../lib/util/sys_rw.c: In function ‘sys_pread_full’: ../../../lib/util/sys_rw.c:219:25: warning: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 219 | if (ret > curr_count) { | ^ ../../../lib/util/sys_rw.c: In function ‘sys_pwrite_full’: ../../../lib/util/sys_rw.c:282:25: warning: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 282 | if (ret > curr_count) { | ^ ../../../lib/util/sys_rw.c: In function ‘sys_write_full’: ../../../lib/util/sys_rw.c:321:25: warning: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 321 | if (ret > curr_count) { | ^ Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke --- diff --git a/lib/util/sys_rw.c b/lib/util/sys_rw.c index 957eafb4aa8..aa3020c74ab 100644 --- a/lib/util/sys_rw.c +++ b/lib/util/sys_rw.c @@ -216,7 +216,7 @@ ssize_t sys_pread_full(int fd, void *buf, size_t count, off_t off) break; } - if (ret > curr_count) { + if ((size_t)ret > curr_count) { errno = EIO; return -1; } @@ -279,7 +279,7 @@ ssize_t sys_pwrite_full(int fd, const void *buf, size_t count, off_t off) return -1; } - if (ret > curr_count) { + if ((size_t)ret > curr_count) { errno = EIO; return -1; } @@ -318,7 +318,7 @@ ssize_t sys_write_full(int fd, const void *buf, size_t count) return -1; } - if (ret > curr_count) { + if ((size_t)ret > curr_count) { errno = EIO; return -1; }