public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] tools/io_uring/io_uring-cp: Fix two compile warings
@ 2023-04-21 12:26 Rong Tao
  0 siblings, 0 replies; only message in thread
From: Rong Tao @ 2023-04-21 12:26 UTC (permalink / raw)
  To: axboe; +Cc: Rong Tao, Pavel Begunkov, open list:IO_URING, open list

From: Rong Tao <[email protected]>

Resolve compilation warnings:

    $ make
    ...
    cc -Wall -Wextra -g -D_GNU_SOURCE -o io_uring-cp io_uring-cp.c \
        setup.o syscall.o queue.o
    io_uring-cp.c: In function ‘copy_file’:
    io_uring-cp.c:158:31: warning: comparison of integer expressions of
    different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
    158 |                 if (had_reads != reads) {
        |                               ^~
    io_uring-cp.c:201:45: warning: comparison of integer expressions of
    different signedness: ‘__s32’ {aka ‘int’} and ‘size_t’ {aka ‘long
    unsigned int’} [-Wsign-compare]
    201 |                    } else if (cqe->res != data->iov.iov_len) {
        |                                        ^~

Signed-off-by: Rong Tao <[email protected]>
---
 tools/io_uring/io_uring-cp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/io_uring/io_uring-cp.c b/tools/io_uring/io_uring-cp.c
index d9bd6f5f8f46..8a0ecaf78bda 100644
--- a/tools/io_uring/io_uring-cp.c
+++ b/tools/io_uring/io_uring-cp.c
@@ -131,7 +131,8 @@ static int copy_file(struct io_uring *ring, off_t insize)
 	writes = reads = offset = 0;
 
 	while (insize || write_left) {
-		int had_reads, got_comp;
+		unsigned long had_reads;
+		int got_comp;
 
 		/*
 		 * Queue up as many reads as we can
@@ -198,7 +199,7 @@ static int copy_file(struct io_uring *ring, off_t insize)
 				fprintf(stderr, "cqe failed: %s\n",
 						strerror(-cqe->res));
 				return 1;
-			} else if (cqe->res != data->iov.iov_len) {
+			} else if ((size_t)cqe->res != data->iov.iov_len) {
 				/* Short read/write, adjust and requeue */
 				data->iov.iov_base += cqe->res;
 				data->iov.iov_len -= cqe->res;
-- 
2.39.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-21 12:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-21 12:26 [PATCH] tools/io_uring/io_uring-cp: Fix two compile warings Rong Tao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox