oslib/linux-blkzoned: fix bogus poiter alignment warning
authorJens Axboe <axboe@kernel.dk>
Tue, 23 Jun 2020 17:41:56 +0000 (11:41 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 23 Jun 2020 17:41:56 +0000 (11:41 -0600)
GCC 10.x reports:

oslib/linux-blkzoned.c: In function ‘blkzoned_report_zones’:
oslib/linux-blkzoned.c:146:18: warning: taking address of packed member of ‘struct blk_zone_report’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  146 |  blkz = (void *) &hdr->zones[0];

which is totally fine, but we can easily avoid this warning by just
setting the 'blkz' pointer to the end of 'hdr'.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
oslib/linux-blkzoned.c

index 61ea3a53d6d5ce1b029db3bef33a18ece1baa4ac..1cf06363d1a2b2b9a8dc9220878b00b64439a44a 100644 (file)
@@ -143,7 +143,7 @@ int blkzoned_report_zones(struct thread_data *td, struct fio_file *f,
        }
 
        nr_zones = hdr->nr_zones;
-       blkz = &hdr->zones[0];
+       blkz = (void *) hdr + sizeof(*hdr);
        z = &zones[0];
        for (i = 0; i < nr_zones; i++, z++, blkz++) {
                z->start = blkz->start << 9;