qemu-io: Improve alignment checks
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é <f4bug@amsat.org> Suggested-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> Message-id: 20170429191419.30051-2-eblake@redhat.com Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
698bdfa07d
commit
1bce6b4ce3
@ -740,13 +740,13 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bflag) {
|
if (bflag) {
|
||||||
if (offset & 0x1ff) {
|
if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
|
||||||
printf("offset %" PRId64 " is not sector aligned\n",
|
printf("%" PRId64 " is not a sector-aligned value for 'offset'\n",
|
||||||
offset);
|
offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (count & 0x1ff) {
|
if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) {
|
||||||
printf("count %"PRId64" is not sector aligned\n",
|
printf("%"PRId64" is not a sector-aligned value for 'count'\n",
|
||||||
count);
|
count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1050,14 +1050,14 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bflag || cflag) {
|
if (bflag || cflag) {
|
||||||
if (offset & 0x1ff) {
|
if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
|
||||||
printf("offset %" PRId64 " is not sector aligned\n",
|
printf("%" PRId64 " is not a sector-aligned value for 'offset'\n",
|
||||||
offset);
|
offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count & 0x1ff) {
|
if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) {
|
||||||
printf("count %"PRId64" is not sector aligned\n",
|
printf("%"PRId64" is not a sector-aligned value for 'count'\n",
|
||||||
count);
|
count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1769,8 +1769,8 @@ static int alloc_f(BlockBackend *blk, int argc, char **argv)
|
|||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
print_cvtnum_err(offset, argv[1]);
|
print_cvtnum_err(offset, argv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (offset & 0x1ff) {
|
} else if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
|
||||||
printf("offset %" PRId64 " is not sector aligned\n",
|
printf("%" PRId64 " is not a sector-aligned value for 'offset'\n",
|
||||||
offset);
|
offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user