All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-trivial@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Fam Zheng <famz@redhat.com>, Juan Quintela <quintela@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Jeff Cody <jcody@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org,
	"Eric Blake" <eblake@redhat.com>
Subject: [Qemu-devel] [PATCH 05/29] block: use QEMU_IS_ALIGNED macro
Date: Tue, 18 Jul 2017 03:09:41 -0300	[thread overview]
Message-ID: <20170718061005.29518-6-f4bug@amsat.org> (raw)
In-Reply-To: <20170718061005.29518-1-f4bug@amsat.org>

Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.cocci

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 block/io.c          | 4 ++--
 block/qcow2-cache.c | 2 +-
 block/vhdx-log.c    | 2 +-
 block/vvfat.c       | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/io.c b/block/io.c
index aece54c015..2db571c310 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1232,7 +1232,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
     int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
                                     MAX_WRITE_ZEROES_BOUNCE_BUFFER);
 
-    assert(alignment % bs->bl.request_alignment == 0);
+    assert(QEMU_IS_ALIGNED(alignment, bs->bl.request_alignment));
     head = offset % alignment;
     tail = (offset + bytes) % alignment;
     max_write_zeroes = QEMU_ALIGN_DOWN(max_write_zeroes, alignment);
@@ -2342,7 +2342,7 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
      * unaligned requests (by returning -ENOTSUP), so we must fragment
      * the request accordingly.  */
     align = MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment);
-    assert(align % bs->bl.request_alignment == 0);
+    assert(QEMU_IS_ALIGNED(align, bs->bl.request_alignment));
     head = offset % align;
     tail = (offset + bytes) % align;
 
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index 1d25147392..a4886c581e 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -58,7 +58,7 @@ static inline int qcow2_cache_get_table_idx(BlockDriverState *bs,
     BDRVQcow2State *s = bs->opaque;
     ptrdiff_t table_offset = (uint8_t *) table - (uint8_t *) c->table_array;
     int idx = table_offset / s->cluster_size;
-    assert(idx >= 0 && idx < c->size && table_offset % s->cluster_size == 0);
+    assert(idx >= 0 && idx < c->size && QEMU_IS_ALIGNED(table_offset, s->cluster_size));
     return idx;
 }
 
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 01278f3fc9..bdcaa4cc16 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -282,7 +282,7 @@ static bool vhdx_log_desc_is_valid(VHDXLogDescriptor *desc,
     }
 
     if (desc->signature == VHDX_LOG_ZERO_SIGNATURE) {
-        if (desc->zero_length % VHDX_LOG_SECTOR_SIZE == 0) {
+        if (QEMU_IS_ALIGNED(desc->zero_length, VHDX_LOG_SECTOR_SIZE)) {
             /* valid */
             ret = true;
         }
diff --git a/block/vvfat.c b/block/vvfat.c
index 4dae790203..5eb827fbd6 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -454,7 +454,7 @@ static direntry_t *create_long_filename(BDRVVVFATState *s, const char *filename)
         entry=array_get(&(s->directory),s->directory.next-1-(i/26));
         if (i >= 2 * length + 2) {
             entry->name[offset] = 0xff;
-        } else if (i % 2 == 0) {
+        } else if (QEMU_IS_ALIGNED(i, 2)) {
             entry->name[offset] = longname[i / 2] & 0xff;
         } else {
             entry->name[offset] = longname[i / 2] >> 8;
-- 
2.13.2

  parent reply	other threads:[~2017-07-18  6:12 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18  6:09 [Qemu-devel] [PATCH 00/29] coccinelle script to enforce qemu/osdep.h macros usage Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 01/29] coccinelle: add a " Philippe Mathieu-Daudé
2017-07-18 15:18   ` Eric Blake
2017-07-18  6:09 ` [Qemu-devel] [PATCH 02/29] pci: remove superfluous parenthesis Philippe Mathieu-Daudé
2017-07-19  0:16   ` Richard Henderson
2017-07-18  6:09 ` [Qemu-devel] [PATCH 03/29] qemu-img: use QEMU_IS_ALIGNED macro Philippe Mathieu-Daudé
2017-07-18 15:19   ` Eric Blake
2017-07-18  6:09 ` [Qemu-devel] [PATCH 04/29] scsi-disk: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` Philippe Mathieu-Daudé [this message]
2017-07-18  9:59   ` [Qemu-devel] [PATCH 05/29] block: " Juan Quintela
2017-07-18 15:25   ` Eric Blake
2017-07-18  6:09 ` [Qemu-devel] [PATCH 06/29] migration/block: " Philippe Mathieu-Daudé
2017-07-18  9:58   ` Juan Quintela
2017-07-18 11:19     ` Alex Bennée
2017-07-18  6:09 ` [Qemu-devel] [PATCH 07/29] ds1338: " Philippe Mathieu-Daudé
2017-07-18 10:23   ` Alastair D'Silva
2017-07-18 13:23     ` Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 08/29] ui: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 09/29] net: " Philippe Mathieu-Daudé
2017-07-18 17:51   ` Eric Blake
2017-07-18  6:09 ` [Qemu-devel] [PATCH 10/29] net/rocker: " Philippe Mathieu-Daudé
2017-07-18 17:51   ` Eric Blake
2017-07-21 16:23     ` Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 11/29] s390x/sclp: " Philippe Mathieu-Daudé
2017-07-18  9:58   ` Cornelia Huck
2017-07-18 10:03     ` Cornelia Huck
2017-07-18  6:09 ` [Qemu-devel] [PATCH 12/29] sm501: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 13/29] tcg: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 14/29] cris: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 15/29] microblaze: " Philippe Mathieu-Daudé
2017-07-18 11:08   ` Marc-André Lureau
2017-07-18 14:46     ` Thomas Huth
2017-07-18  6:09 ` [Qemu-devel] [PATCH 16/29] lm32: " Philippe Mathieu-Daudé
2017-07-18 11:42   ` Michael Walle
2017-07-18 14:37     ` Thomas Huth
2017-07-21 16:29       ` Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 18/29] nios2: " Philippe Mathieu-Daudé
2017-07-18  6:09 ` [Qemu-devel] [PATCH 19/29] disas: " Philippe Mathieu-Daudé
2017-07-18 11:07   ` Marc-André Lureau
2017-07-18 14:43     ` Thomas Huth
2017-07-23 14:52       ` Paolo Bonzini
2017-07-24 12:16         ` Eric Blake
2017-07-18 11:09   ` Michael Tokarev
2017-07-18  6:09 ` [Qemu-devel] [PATCH 20/29] disas: use ARRAY_SIZE macro Philippe Mathieu-Daudé
2017-07-18  6:49   ` David Gibson
2017-07-18 10:55   ` Marc-André Lureau
2017-07-18  6:09 ` [Qemu-devel] [PATCH 21/29] qga: " Philippe Mathieu-Daudé
2017-07-18 11:29   ` Marc-André Lureau
2017-07-18  6:09 ` [Qemu-devel] [PATCH 22/29] vmsvga: " Philippe Mathieu-Daudé
2017-07-18 11:28   ` Marc-André Lureau
2017-07-18  6:09 ` [Qemu-devel] [PATCH 23/29] async: " Philippe Mathieu-Daudé
2017-07-18 10:54   ` Marc-André Lureau
2017-07-18  6:10 ` [Qemu-devel] [PATCH 24/29] tests/acpi: " Philippe Mathieu-Daudé
2017-07-18  6:10 ` [Qemu-devel] [PATCH 25/29] libqos: " Philippe Mathieu-Daudé
2017-07-18 11:00   ` Marc-André Lureau
2017-07-18 11:58   ` Laurent Vivier
2017-07-18 13:36     ` Philippe Mathieu-Daudé
2017-07-18  6:10 ` [Qemu-devel] [PATCH 26/29] tests/tcg: " Philippe Mathieu-Daudé
2017-07-18 10:56   ` Marc-André Lureau
2017-07-18 11:16     ` Alex Bennée
2017-07-18 11:24       ` Marc-André Lureau
2017-07-18 13:52         ` Alex Bennée
2017-07-18 13:41       ` Philippe Mathieu-Daudé
2017-07-18  6:10 ` [Qemu-devel] [PATCH 27/29] tests/hbitmap: " Philippe Mathieu-Daudé
2017-07-18 10:52   ` Marc-André Lureau
2017-07-18 15:36   ` John Snow
2017-07-18  6:10 ` [Qemu-devel] [PATCH 28/29] tests/qapi: use QEMU_IS_ALIGNED macro Philippe Mathieu-Daudé
2017-07-18 10:53   ` Marc-André Lureau
2017-07-18  6:10 ` [Qemu-devel] [PATCH 29/29] tests/qapi: use ARRAY_SIZE macro Philippe Mathieu-Daudé
2017-07-18 10:52   ` Marc-André Lureau

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=20170718061005.29518-6-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.