[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 37/58] qemu-io: Improve alignment checks
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 37/58] qemu-io: Improve alignment checks |
Date: |
Thu, 11 May 2017 16:32:40 +0200 |
From: Eric Blake <address@hidden>
Several copy-and-pasted alignment checks exist in qemu-io, which
could use some minor improvements:
- Manual comparison against 0x1ff is not as clean as using our
alignment macros (QEMU_IS_ALIGNED) from osdep.h.
- The error messages aren't quite grammatically correct.
Suggested-by: Philippe Mathieu-Daudé <address@hidden>
Suggested-by: Max Reitz <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
Message-id: address@hidden
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
qemu-io-cmds.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 21af9e6..6a0024b 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -740,13 +740,13 @@ static int read_f(BlockBackend *blk, int argc, char
**argv)
}
if (bflag) {
- if (offset & 0x1ff) {
- printf("offset %" PRId64 " is not sector aligned\n",
+ if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
+ printf("%" PRId64 " is not a sector-aligned value for 'offset'\n",
offset);
return 0;
}
- if (count & 0x1ff) {
- printf("count %"PRId64" is not sector aligned\n",
+ if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) {
+ printf("%"PRId64" is not a sector-aligned value for 'count'\n",
count);
return 0;
}
@@ -1050,14 +1050,14 @@ static int write_f(BlockBackend *blk, int argc, char
**argv)
}
if (bflag || cflag) {
- if (offset & 0x1ff) {
- printf("offset %" PRId64 " is not sector aligned\n",
+ if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
+ printf("%" PRId64 " is not a sector-aligned value for 'offset'\n",
offset);
return 0;
}
- if (count & 0x1ff) {
- printf("count %"PRId64" is not sector aligned\n",
+ if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) {
+ printf("%"PRId64" is not a sector-aligned value for 'count'\n",
count);
return 0;
}
@@ -1769,8 +1769,8 @@ static int alloc_f(BlockBackend *blk, int argc, char
**argv)
if (offset < 0) {
print_cvtnum_err(offset, argv[1]);
return 0;
- } else if (offset & 0x1ff) {
- printf("offset %" PRId64 " is not sector aligned\n",
+ } else if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
+ printf("%" PRId64 " is not a sector-aligned value for 'offset'\n",
offset);
return 0;
}
--
1.8.3.1
- [Qemu-devel] [PULL 29/58] block: New BdrvChildRole.activate() for blk_resume_after_migration(), (continued)
- [Qemu-devel] [PULL 29/58] block: New BdrvChildRole.activate() for blk_resume_after_migration(), Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 34/58] qemu-img: wait for convert coroutines to complete, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 30/58] block: Drop permissions when migration completes, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 35/58] nvme: Implement Write Zeroes, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 36/58] blockdev: use drained_begin/end for qmp_block_resize, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 31/58] block: Inactivate parents before children, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 33/58] file-posix: Remove .bdrv_inactivate/invalidate_cache, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 32/58] block: Fix write/resize permissions for inactive images, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 38/58] qemu-io: Switch 'alloc' command to byte-based length, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 40/58] blkdebug: Sanity check block layer guarantees, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 37/58] qemu-io: Improve alignment checks,
Kevin Wolf <=
- [Qemu-devel] [PULL 41/58] blkdebug: Refactor error injection, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 42/58] blkdebug: Add pass-through write_zero and discard support, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 39/58] qemu-io: Switch 'map' output to byte-based reporting, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 43/58] blkdebug: Simplify override logic, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 44/58] blkdebug: Add ability to override unmap geometries, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 47/58] qcow2: Use consistent switch indentation, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 45/58] tests: Add coverage for recent block geometry fixes, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 46/58] qcow2: Nicer variable names in qcow2_update_snapshot_refcount(), Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 48/58] block: Update comments on BDRV_BLOCK_* meanings, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 49/58] qcow2: Correctly report status of preallocated zero clusters, Kevin Wolf, 2017/05/11