From 8dd8d56d95763ffc914bb729eb27d720cd8ab5eb Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Sun, 4 Dec 2022 16:31:05 -0800 Subject: [PATCH] posixshm_test: Fix sign mismatches in ?: results. GCC 12's -Wsign-compare complains if the two alternative results of the ?: operator are differently signed. Cast the small, sub-page off_t values to size_t to quiet the warning. Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D37539 --- tests/sys/posixshm/posixshm_test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sys/posixshm/posixshm_test.c b/tests/sys/posixshm/posixshm_test.c index c84eca319e0..6398f5f6e08 100644 --- a/tests/sys/posixshm/posixshm_test.c +++ b/tests/sys/posixshm/posixshm_test.c @@ -195,7 +195,7 @@ shm_fill(int fd, off_t offset, off_t len) return (1); while (len > 0) { - blen = len < (off_t)page_size ? len : page_size; + blen = len < (off_t)page_size ? (size_t)len : page_size; memset(buf, byte_to_fill, blen); if (pwrite(fd, buf, blen, offset) != (ssize_t)blen) { error = 1; @@ -236,7 +236,7 @@ check_content_dealloc(int fd, off_t hole_start, off_t hole_len, off_t shm_sz) offset = hole_start; resid = hole_len; while (resid > 0) { - blen = resid < (off_t)page_size ? resid : page_size; + blen = resid < (off_t)page_size ? (size_t)resid : page_size; if (pread(fd, buf, blen, offset) != (ssize_t)blen) { error = 1; break; @@ -257,7 +257,7 @@ check_content_dealloc(int fd, off_t hole_start, off_t hole_len, off_t shm_sz) offset = 0; resid = hole_start; while (resid > 0) { - blen = resid < (off_t)page_size ? resid : page_size; + blen = resid < (off_t)page_size ? (size_t)resid : page_size; if (pread(fd, buf, blen, offset) != (ssize_t)blen) { error = 1; break; @@ -276,7 +276,7 @@ check_content_dealloc(int fd, off_t hole_start, off_t hole_len, off_t shm_sz) offset = hole_start + hole_len; resid = shm_sz - offset; while (resid > 0) { - blen = resid < (off_t)page_size ? resid : page_size; + blen = resid < (off_t)page_size ? (size_t)resid : page_size; if (pread(fd, buf, blen, offset) != (ssize_t)blen) { error = 1; break;