Skip to contentSkip to conversation

nbd: use correct div_s64 helper

PATCH In review Arnd Bergmann 2 participants 2 messages Mar 4, 2016 – Mar 5, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nbd: use correct div_s64 helper

The do_div() macro now checks its arguments for the correct type, and refuses anything other than u64, so we get a warning about nbd_ioctl passing in an loff_t:

drivers/block/nbd.c: In function '__nbd_ioctl':
drivers/block/nbd.c:757:77: error: comparison of distinct pointer types lacks a cast [-Werror]

This changes the nbd code to use div_s64() instead, which takes a signed argument.

Fixes 37091fdd831f ("nbd: Create size change events for userspace")
---
 drivers/block/nbd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/nbd.c +1 -2
index f6b51d76e578..08afbc7a2bb8 100644
@@ -753,8 +753,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
 	}
 
 	case NBD_SET_BLKSIZE: {
-		loff_t bsize = nbd->bytesize;
-		do_div(bsize, arg);
+		loff_t bsize = div_s64(nbd->bytesize, arg);
 
 		return nbd_size_set(nbd, bdev, arg, bsize);
 	}
Signature · 1 line
2.7.0
#1 lore raw
Quoted 9 lines · Arnd Bergmann

The do_div() macro now checks its arguments for the correct type, and refuses anything other than u64, so we get a warning about nbd_ioctl passing in an loff_t:

drivers/block/nbd.c: In function '__nbd_ioctl':
drivers/block/nbd.c:757:77: error: comparison of distinct pointer types lacks a cast [-Werror]

This changes the nbd code to use div_s64() instead, which takes a signed argument.

Thanks Arnd, applied.

Signature · 1 line
Jens Axboe