From 8f823b93cfd71348e98f33d21c99b18c64fa339f Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 4 Aug 2017 14:15:46 -0700 Subject: [PATCH] bdev: make spdk_bdev_io_valid() return bool Swap the meaning of the return value to match the name of the function. Change-Id: I89dc09e3b309a06586adf2ab750092f06077ffd9 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/372859 Reviewed-by: Ben Walker Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- lib/bdev/bdev.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 3cc2e4da4..153f24018 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -739,26 +739,26 @@ spdk_bdev_has_write_cache(const struct spdk_bdev *bdev) return bdev->write_cache; } -static int +static bool spdk_bdev_io_valid(struct spdk_bdev *bdev, uint64_t offset, uint64_t nbytes) { /* Return failure if nbytes is not a multiple of bdev->blocklen */ if (nbytes % bdev->blocklen) { - return -1; + return false; } /* Return failure if offset + nbytes is less than offset; indicates there * has been an overflow and hence the offset has been wrapped around */ if (offset + nbytes < offset) { - return -1; + return false; } /* Return failure if offset + nbytes exceeds the size of the bdev */ if (offset + nbytes > bdev->blockcnt * bdev->blocklen) { - return -1; + return false; } - return 0; + return true; } int @@ -771,7 +771,7 @@ spdk_bdev_read(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); int rc; - if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) { + if (!spdk_bdev_io_valid(bdev, offset, nbytes)) { return -EINVAL; } @@ -811,7 +811,7 @@ spdk_bdev_readv(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch); int rc; - if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) { + if (!spdk_bdev_io_valid(bdev, offset, nbytes)) { return -EINVAL; } @@ -852,7 +852,7 @@ spdk_bdev_write(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, return -EBADF; } - if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) { + if (!spdk_bdev_io_valid(bdev, offset, nbytes)) { return -EINVAL; } @@ -896,7 +896,7 @@ spdk_bdev_writev(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, return -EBADF; } - if (spdk_bdev_io_valid(bdev, offset, len) != 0) { + if (!spdk_bdev_io_valid(bdev, offset, len)) { return -EINVAL; } @@ -937,7 +937,7 @@ spdk_bdev_unmap(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, return -EBADF; } - if (spdk_bdev_io_valid(bdev, offset, nbytes) != 0) { + if (!spdk_bdev_io_valid(bdev, offset, nbytes)) { return -EINVAL; }