From 8310c57050e7c89a1454cbf7732e81ba83d668d7 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Tue, 21 Dec 2021 11:07:58 -0500 Subject: [PATCH] t/io_uring: fix 32-bit build warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Also change the type for offset to long long since that's what is expected by io_prep_pread. Latency measurement for t/io_uring is actually broken on 32-bit builds because iocb->data and io_event->data are 32-bit void pointers. So it is not possible to fit both fileno and clock_index in there. On a 32-bit build with 4-byte longs, the following warnings appear: t/io_uring.c: In function ‘prep_more_ios_aio’: t/io_uring.c:666:44: error: left shift count >= width of type [-Werror=shift-count-overflow] 666 | data |= ((unsigned long) s->clock_index << 32); | ^~ t/io_uring.c: In function ‘reap_events_aio’: t/io_uring.c:688:27: error: right shift count >= width of type [-Werror=shift-count-overflow] 688 | int clock_index = data >> 32; | ^~ Explicitly specify 64-bit types to resolve these warnings. Signed-off-by: Vincent Fu --- t/io_uring.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/t/io_uring.c b/t/io_uring.c index a98f78fd..755796dd 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -634,7 +634,8 @@ static int submitter_init(struct submitter *s) #ifdef CONFIG_LIBAIO static int prep_more_ios_aio(struct submitter *s, int max_ios, struct iocb *iocbs) { - unsigned long offset, data; + uint64_t data; + long long offset; struct file *f; unsigned index; long r; @@ -663,7 +664,7 @@ static int prep_more_ios_aio(struct submitter *s, int max_ios, struct iocb *iocb data = f->fileno; if (stats && stats_running) - data |= ((unsigned long) s->clock_index << 32); + data |= (((uint64_t) s->clock_index) << 32); iocb->data = (void *) (uintptr_t) data; index++; } @@ -676,7 +677,7 @@ static int reap_events_aio(struct submitter *s, struct io_event *events, int evs int reaped = 0; while (evs) { - unsigned long data = (uintptr_t) events[reaped].data; + uint64_t data = (uintptr_t) events[reaped].data; struct file *f = &s->files[data & 0xffffffff]; f->pending_ios--; -- 2.25.1