t/io_uring: fix 32-bit build warnings
authorVincent Fu <vincent.fu@samsung.com>
Tue, 21 Dec 2021 16:07:58 +0000 (11:07 -0500)
committerVincent Fu <vincent.fu@samsung.com>
Thu, 23 Dec 2021 20:55:20 +0000 (15:55 -0500)
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 <vincent.fu@samsung.com>
t/io_uring.c

index a98f78fd4a768af2736edb5c090282947b99e4f1..755796dd2cdcf74a89609157f44c04ba7465d722 100644 (file)
@@ -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--;