]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
util: Avoid signed/unsigned integer comparisons
authorMartin Schwenke <mschwenke@ddn.com>
Sun, 22 Sep 2024 06:37:50 +0000 (16:37 +1000)
committerVolker Lendecke <vl@samba.org>
Mon, 9 Feb 2026 11:17:41 +0000 (11:17 +0000)
../../../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 <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
lib/util/sys_rw.c

index 957eafb4aa869dc4d9d7e3987e65680cb60e0eae..aa3020c74ab46258d7037abfa43381ab80259131 100644 (file)
@@ -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;
                }