From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v11 1/9] qemu-io: Improve alignment checks
Date: Sat, 29 Apr 2017 19:39:34 -0300 [thread overview]
Message-ID: <092c17fb-3b2b-1779-8ea0-df6329adb4fe@amsat.org> (raw)
In-Reply-To: <20170429191419.30051-2-eblake@redhat.com>
On 04/29/2017 04:14 PM, Eric Blake wrote:
> 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>
>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> v11: retitle [was "qemu-io: Don't open-code QEMU_IS_ALIGNED"], improve
> error messages
> v10: new patch
> ---
> 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;
> }
>
next prev parent reply other threads:[~2017-04-29 22:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-29 19:14 [Qemu-devel] [PATCH v11 0/9] add blkdebug tests Eric Blake
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 1/9] qemu-io: Improve alignment checks Eric Blake
2017-04-29 22:39 ` Philippe Mathieu-Daudé [this message]
2017-05-03 18:42 ` Max Reitz
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 2/9] qemu-io: Switch 'alloc' command to byte-based length Eric Blake
2017-05-03 18:44 ` Max Reitz
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 3/9] qemu-io: Switch 'map' output to byte-based reporting Eric Blake
2017-05-03 18:54 ` Max Reitz
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 4/9] blkdebug: Sanity check block layer guarantees Eric Blake
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 5/9] blkdebug: Refactor error injection Eric Blake
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 6/9] blkdebug: Add pass-through write_zero and discard support Eric Blake
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 7/9] blkdebug: Simplify override logic Eric Blake
2017-05-03 18:59 ` Max Reitz
2017-05-03 19:01 ` Max Reitz
2017-05-03 19:03 ` Eric Blake
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 8/9] blkdebug: Add ability to override unmap geometries Eric Blake
2017-04-29 19:14 ` [Qemu-devel] [PATCH v11 9/9] tests: Add coverage for recent block geometry fixes Eric Blake
2017-05-05 22:34 ` Max Reitz
2017-05-05 22:48 ` Eric Blake
2017-05-03 19:07 ` [Qemu-devel] [PATCH v11 0/9] add blkdebug tests Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=092c17fb-3b2b-1779-8ea0-df6329adb4fe@amsat.org \
--to=f4bug@amsat.org \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).