All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy
@ 2017-07-13 16:31 Marc-André Lureau
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro Marc-André Lureau
                   ` (29 more replies)
  0 siblings, 30 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, peter.maydell, Marc-André Lureau

Hi,

Various refactring questions on previously sent series prompted me to
look at coccinelle to automate some changes again. Alas, semantic
patches are not so easy to express for me, cocci doesn't catch all
cases, is quite slow, and it doesn't seem possible to evaluate
expressions to check if E == E-1 or if E is pow2 for example.

I started looking at clang-tidy
(http://clang.llvm.org/extra/clang-tidy/) as an alternative to do some
refactoring.

Our build-system doesn't generate compile_commands.json, which is
pretty much required to use clang refactoring tools. But it is as easy
as running "bear make" to make one, using https://github.com/rizsotto/Bear.

Then, you can run checks and automate fixes (here only "qemu-round")
over the code base with:
run-clang-tidy.py -header-filter='.*' -checks='-*,qemu-round' -fix

There are some path bugs that can easily be solved, see
https://bugs.llvm.org/show_bug.cgi?id=33440 for details.

I ran 'qemu-round' check in this series, and added a few other manual
refactoring I had pending. (I'll submit other series for the rest of
the checks later)

My WIP qemu checks are here:
https://github.com/elmarco/clang-tools-extra/tree/master/clang-tidy/qemu

The "round-check" is:
https://github.com/elmarco/clang-tools-extra/blob/master/clang-tidy/qemu/RoundCheck.cpp

I don't know if you can express a semantic patch that would be as
powerful. The code remains easy to write & read imho, and quite fast
to apply. I like the tool, it's probably a good complement to
coccinelle overall.

v2:
- rebased, and resent to CC qemu-trivial
- drop slirp patch, as Samuel said he applied it on his tree
- added r-b/a-b tags

Thanks

Marc-André Lureau (29):
  i386: use ROUND_UP macro
  vnc: use QEMU_ALIGN_DOWN
  vhdx: use QEMU_ALIGN_DOWN
  vhost: use QEMU_ALIGN_DOWN
  i8254: use QEMU_ALIGN_DOWN
  pcspk: use QEMU_ALIGN_DOWN
  dmg: use DIV_ROUND_UP
  qcow2: use DIV_ROUND_UP
  vpc: use DIV_ROUND_UP
  vvfat: use DIV_ROUND_UP
  vnc: use DIV_ROUND_UP
  ui: use DIV_ROUND_UP
  vga: use DIV_ROUND_UP
  virtio-gpu: use DIV_ROUND_UP
  monitor: use DIV_ROUND_UP
  console: use DIV_ROUND_UP
  virtio-serial: use DIV_ROUND_UP
  piix: use DIV_ROUND_UP
  q35: use DIV_ROUND_UP
  usb-hub: use DIV_ROUND_UP
  msix: use DIV_ROUND_UP
  ppc: use DIV_ROUND_UP
  i386/dump: use DIV_ROUND_UP
  kvm: use DIV_ROUND_UP
  decnumber: use DIV_ROUND_UP
  i386: introduce ELF_NOTE_SIZE macro
  i386: replace g_malloc()+memcpy() with g_memdup()
  test-iov: replace g_malloc()+memcpy() with g_memdup()
  eepro100: replace g_malloc()+memcpy() with g_memdup()

 include/ui/console.h        |  2 +-
 linux-headers/asm-x86/kvm.h |  2 +-
 block/dmg.c                 |  2 +-
 block/qcow2-cluster.c       |  2 +-
 block/vhdx-log.c            |  2 +-
 block/vpc.c                 |  4 ++--
 block/vvfat.c               |  4 ++--
 hw/audio/pcspk.c            |  2 +-
 hw/char/virtio-serial-bus.c |  8 ++++----
 hw/display/vga.c            |  2 +-
 hw/display/virtio-gpu.c     |  4 ++--
 hw/i386/multiboot.c         |  3 +--
 hw/net/eepro100.c           |  3 +--
 hw/pci-host/piix.c          |  2 +-
 hw/pci-host/q35.c           |  2 +-
 hw/pci/msix.c               |  4 ++--
 hw/timer/i8254_common.c     |  4 ++--
 hw/usb/dev-hub.c            |  8 ++++----
 hw/virtio/vhost.c           |  2 +-
 libdecnumber/decNumber.c    |  2 +-
 monitor.c                   |  4 ++--
 target/i386/arch_dump.c     | 40 ++++++++++++++++++++--------------------
 target/ppc/mem_helper.c     |  2 +-
 target/ppc/translate.c      |  2 +-
 tests/test-iov.c            |  3 +--
 ui/cursor.c                 |  2 +-
 ui/vnc-enc-tight.c          |  2 +-
 ui/vnc.c                    | 10 +++++-----
 28 files changed, 63 insertions(+), 66 deletions(-)

-- 
2.13.1.395.gf7b71de06

^ permalink raw reply	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-13 16:35   ` Eduardo Habkost
  2017-07-14  8:10   ` Richard Henderson
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 02/29] vnc: use QEMU_ALIGN_DOWN Marc-André Lureau
                   ` (28 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	Paolo Bonzini, Richard Henderson, Eduardo Habkost

I used the clang-tidy qemu-round check (with the option OnlyAlignUp)
to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
---
 target/i386/arch_dump.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c
index fe0aa36932..1d51bb5206 100644
--- a/target/i386/arch_dump.c
+++ b/target/i386/arch_dump.c
@@ -84,9 +84,9 @@ static int x86_64_write_elf64_note(WriteCoreDumpFunction f,
     note->n_descsz = cpu_to_le32(descsz);
     note->n_type = cpu_to_le32(NT_PRSTATUS);
     buf = (char *)note;
-    buf += ((sizeof(Elf64_Nhdr) + 3) / 4) * 4;
+    buf += ROUND_UP(sizeof(Elf64_Nhdr), 4);
     memcpy(buf, name, name_size);
-    buf += ((name_size + 3) / 4) * 4;
+    buf += ROUND_UP(name_size, 4);
     memcpy(buf + 32, &id, 4); /* pr_pid */
     buf += descsz - sizeof(x86_64_user_regs_struct)-sizeof(target_ulong);
     memcpy(buf, &regs, sizeof(x86_64_user_regs_struct));
@@ -163,9 +163,9 @@ static int x86_write_elf64_note(WriteCoreDumpFunction f, CPUX86State *env,
     note->n_descsz = cpu_to_le32(descsz);
     note->n_type = cpu_to_le32(NT_PRSTATUS);
     buf = (char *)note;
-    buf += ((sizeof(Elf64_Nhdr) + 3) / 4) * 4;
+    buf += ROUND_UP(sizeof(Elf64_Nhdr), 4);
     memcpy(buf, name, name_size);
-    buf += ((name_size + 3) / 4) * 4;
+    buf += ROUND_UP(name_size, 4);
     memcpy(buf, &prstatus, sizeof(prstatus));
 
     ret = f(note, note_size, opaque);
@@ -218,9 +218,9 @@ int x86_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
     note->n_descsz = cpu_to_le32(descsz);
     note->n_type = cpu_to_le32(NT_PRSTATUS);
     buf = (char *)note;
-    buf += ((sizeof(Elf32_Nhdr) + 3) / 4) * 4;
+    buf += ROUND_UP(sizeof(Elf32_Nhdr), 4);
     memcpy(buf, name, name_size);
-    buf += ((name_size + 3) / 4) * 4;
+    buf += ROUND_UP(name_size, 4);
     memcpy(buf, &prstatus, sizeof(prstatus));
 
     ret = f(note, note_size, opaque);
@@ -353,9 +353,9 @@ static inline int cpu_write_qemu_note(WriteCoreDumpFunction f,
         note64->n_type = 0;
     }
     buf = note;
-    buf += ((note_head_size + 3) / 4) * 4;
+    buf += ROUND_UP(note_head_size, 4);
     memcpy(buf, name, name_size);
-    buf += ((name_size + 3) / 4) * 4;
+    buf += ROUND_UP(name_size, 4);
     memcpy(buf, &state, sizeof(state));
 
     ret = f(note, note_size, opaque);
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 02/29] vnc: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-14  8:11   ` Richard Henderson
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 03/29] vhdx: " Marc-André Lureau
                   ` (27 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Gerd Hoffmann

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/vnc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 26136f5d29..9710f11be8 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2624,8 +2624,8 @@ static int vnc_refresh_lossy_rect(VncDisplay *vd, int x, int y)
     int stx = x / VNC_STAT_RECT;
     int has_dirty = 0;
 
-    y = y / VNC_STAT_RECT * VNC_STAT_RECT;
-    x = x / VNC_STAT_RECT * VNC_STAT_RECT;
+    y = QEMU_ALIGN_DOWN(y, VNC_STAT_RECT);
+    x = QEMU_ALIGN_DOWN(x, VNC_STAT_RECT);
 
     QTAILQ_FOREACH(vs, &vd->clients, next) {
         int j;
@@ -2714,8 +2714,8 @@ double vnc_update_freq(VncState *vs, int x, int y, int w, int h)
     double total = 0;
     int num = 0;
 
-    x =  (x / VNC_STAT_RECT) * VNC_STAT_RECT;
-    y =  (y / VNC_STAT_RECT) * VNC_STAT_RECT;
+    x =  QEMU_ALIGN_DOWN(x, VNC_STAT_RECT);
+    y =  QEMU_ALIGN_DOWN(y, VNC_STAT_RECT);
 
     for (j = y; j <= y + h; j += VNC_STAT_RECT) {
         for (i = x; i <= x + w; i += VNC_STAT_RECT) {
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 03/29] vhdx: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro Marc-André Lureau
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 02/29] vnc: use QEMU_ALIGN_DOWN Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-13 20:19   ` Eric Blake
  2017-07-14  8:11   ` Richard Henderson
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 04/29] vhost: " Marc-André Lureau
                   ` (26 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Jeff Cody,
	Kevin Wolf, Max Reitz, open list:VHDX

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 block/vhdx-log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 01278f3fc9..ad70706b99 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -884,7 +884,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s,
     }
 
     sector_offset = offset % VHDX_LOG_SECTOR_SIZE;
-    file_offset = (offset / VHDX_LOG_SECTOR_SIZE) * VHDX_LOG_SECTOR_SIZE;
+    file_offset = QEMU_ALIGN_DOWN(offset, VHDX_LOG_SECTOR_SIZE);
 
     aligned_length = length;
 
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 04/29] vhost: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (2 preceding siblings ...)
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 03/29] vhdx: " Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-14  8:12   ` Richard Henderson
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 05/29] i8254: " Marc-André Lureau
                   ` (25 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Michael S. Tsirkin

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6eddb099b0..0049a2c0b3 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -70,7 +70,7 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
     uint64_t end = MIN(mlast, rlast);
     vhost_log_chunk_t *from = log + start / VHOST_LOG_CHUNK;
     vhost_log_chunk_t *to = log + end / VHOST_LOG_CHUNK + 1;
-    uint64_t addr = (start / VHOST_LOG_CHUNK) * VHOST_LOG_CHUNK;
+    uint64_t addr = QEMU_ALIGN_DOWN(start, VHOST_LOG_CHUNK);
 
     if (end < start) {
         return;
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 05/29] i8254: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (3 preceding siblings ...)
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 04/29] vhost: " Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-14  4:17   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
  2017-07-14  8:12   ` [Qemu-devel] " Richard Henderson
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 06/29] pcspk: " Marc-André Lureau
                   ` (24 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	Michael S. Tsirkin, Paolo Bonzini

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/timer/i8254_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
index 976d5200f1..ee064aa819 100644
--- a/hw/timer/i8254_common.c
+++ b/hw/timer/i8254_common.c
@@ -93,7 +93,7 @@ int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time)
         }
         break;
     case 2:
-        base = (d / s->count) * s->count;
+        base = QEMU_ALIGN_DOWN(d, s->count);
         if ((d - base) == 0 && d != 0) {
             next_time = base + s->count;
         } else {
@@ -101,7 +101,7 @@ int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time)
         }
         break;
     case 3:
-        base = (d / s->count) * s->count;
+        base = QEMU_ALIGN_DOWN(d, s->count);
         period2 = ((s->count + 1) >> 1);
         if ((d - base) < period2) {
             next_time = base + period2;
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 06/29] pcspk: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (4 preceding siblings ...)
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 05/29] i8254: " Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-14  8:29   ` Richard Henderson
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 07/29] dmg: use DIV_ROUND_UP Marc-André Lureau
                   ` (23 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Gerd Hoffmann

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/audio/pcspk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index f643b122bb..0206f7399b 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -69,7 +69,7 @@ static inline void generate_samples(PCSpkState *s)
         const uint32_t n = ((uint64_t)PIT_FREQ << 32) / m;
 
         /* multiple of wavelength for gapless looping */
-        s->samples = (PCSPK_BUF_LEN * PIT_FREQ / m * m / (PIT_FREQ >> 1) + 1) >> 1;
+        s->samples = (QEMU_ALIGN_DOWN(PCSPK_BUF_LEN * PIT_FREQ, m) / (PIT_FREQ >> 1) + 1) >> 1;
         for (i = 0; i < s->samples; ++i)
             s->sample_buf[i] = (64 & (n * i >> 25)) - 32;
     } else {
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 07/29] dmg: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (5 preceding siblings ...)
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 06/29] pcspk: " Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-14  8:31   ` Richard Henderson
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 08/29] qcow2: " Marc-André Lureau
                   ` (22 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	Stefan Hajnoczi, Kevin Wolf, Max Reitz, open list:dmg

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/dmg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/dmg.c b/block/dmg.c
index 900ae5a678..6c0711f563 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -111,7 +111,7 @@ static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk,
         uncompressed_sectors = s->sectorcounts[chunk];
         break;
     case 1: /* copy */
-        uncompressed_sectors = (s->lengths[chunk] + 511) / 512;
+        uncompressed_sectors = DIV_ROUND_UP(s->lengths[chunk], 512);
         break;
     case 2: /* zero */
         /* as the all-zeroes block may be large, it is treated specially: the
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 08/29] qcow2: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (6 preceding siblings ...)
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 07/29] dmg: use DIV_ROUND_UP Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-13 20:20   ` Eric Blake
  2017-07-14  8:32   ` Richard Henderson
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 09/29] vpc: " Marc-André Lureau
                   ` (21 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Kevin Wolf,
	Max Reitz, open list:qcow2

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 block/qcow2-cluster.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index f06c08f64c..30db942dde 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -61,7 +61,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
             new_l1_size = 1;
         }
         while (min_size > new_l1_size) {
-            new_l1_size = (new_l1_size * 3 + 1) / 2;
+            new_l1_size = DIV_ROUND_UP(new_l1_size * 3, 2);
         }
     }
 
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 09/29] vpc: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (7 preceding siblings ...)
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 08/29] qcow2: " Marc-André Lureau
@ 2017-07-13 16:31 ` Marc-André Lureau
  2017-07-13 20:20   ` Eric Blake
  2017-07-14  8:34   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 10/29] vvfat: " Marc-André Lureau
                   ` (20 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Kevin Wolf,
	Max Reitz, open list:vpc

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 block/vpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/vpc.c b/block/vpc.c
index 9a6f8173a5..c88dc72491 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -760,7 +760,7 @@ static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
     } else {
         *secs_per_cyl = 17;
         cyls_times_heads = total_sectors / *secs_per_cyl;
-        *heads = (cyls_times_heads + 1023) / 1024;
+        *heads = DIV_ROUND_UP(cyls_times_heads, 1024);
 
         if (*heads < 4) {
             *heads = 4;
@@ -813,7 +813,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
     offset = 3 * 512;
 
     memset(buf, 0xFF, 512);
-    for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) {
+    for (i = 0; i < DIV_ROUND_UP(num_bat_entries * 4, 512); i++) {
         ret = blk_pwrite(blk, offset, buf, 512, 0);
         if (ret < 0) {
             goto fail;
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 10/29] vvfat: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (8 preceding siblings ...)
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 09/29] vpc: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-13 20:21   ` Eric Blake
  2017-07-14  8:35   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 11/29] vnc: " Marc-André Lureau
                   ` (19 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Kevin Wolf,
	Max Reitz, open list:vvfat

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 block/vvfat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/vvfat.c b/block/vvfat.c
index 4fd28e1e87..c08c4fb525 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -437,7 +437,7 @@ static direntry_t *create_long_filename(BDRVVVFATState *s, const char *filename)
         return NULL;
     }
 
-    number_of_entries = (length * 2 + 25) / 26;
+    number_of_entries = DIV_ROUND_UP(length * 2, 26);
 
     for(i=0;i<number_of_entries;i++) {
         entry=array_get_next(&(s->directory));
@@ -2520,7 +2520,7 @@ static int commit_one_file(BDRVVVFATState* s,
                 (size > offset && c >=2 && !fat_eof(s, c)));
 
         ret = vvfat_read(s->bs, cluster2sector(s, c),
-            (uint8_t*)cluster, (rest_size + 0x1ff) / 0x200);
+            (uint8_t*)cluster, DIV_ROUND_UP(rest_size, 0x200));
 
         if (ret < 0) {
             qemu_close(fd);
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 11/29] vnc: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (9 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 10/29] vvfat: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  8:36   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 12/29] ui: " Marc-André Lureau
                   ` (18 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Gerd Hoffmann

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/vnc-enc-tight.c | 2 +-
 ui/vnc.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 89ab12c0d8..f38aceb4da 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -979,7 +979,7 @@ static int send_mono_rect(VncState *vs, int x, int y,
     }
 #endif
 
-    bytes = ((w + 7) / 8) * h;
+    bytes = (DIV_ROUND_UP(w, 8)) * h;
 
     vnc_write_u8(vs, (stream | VNC_TIGHT_EXPLICIT_FILTER) << 4);
     vnc_write_u8(vs, VNC_TIGHT_FILTER_PALETTE);
diff --git a/ui/vnc.c b/ui/vnc.c
index 9710f11be8..dcf7f8ae93 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2781,7 +2781,7 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
             PIXMAN_FORMAT_BPP(pixman_image_get_format(vd->guest.fb));
         guest_row0 = (uint8_t *)pixman_image_get_data(vd->guest.fb);
         guest_stride = pixman_image_get_stride(vd->guest.fb);
-        guest_ll = pixman_image_get_width(vd->guest.fb) * ((guest_bpp + 7) / 8);
+        guest_ll = pixman_image_get_width(vd->guest.fb) * (DIV_ROUND_UP(guest_bpp, 8));
     }
     line_bytes = MIN(server_stride, guest_ll);
 
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 12/29] ui: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (10 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 11/29] vnc: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  4:23   ` Philippe Mathieu-Daudé
  2017-07-14  8:36   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 13/29] vga: " Marc-André Lureau
                   ` (17 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Gerd Hoffmann

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/cursor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/cursor.c b/ui/cursor.c
index 5155b392e8..2e2fe13fa6 100644
--- a/ui/cursor.c
+++ b/ui/cursor.c
@@ -118,7 +118,7 @@ void cursor_put(QEMUCursor *c)
 
 int cursor_get_mono_bpl(QEMUCursor *c)
 {
-    return (c->width + 7) / 8;
+    return DIV_ROUND_UP(c->width, 8);
 }
 
 void cursor_set_mono(QEMUCursor *c,
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 13/29] vga: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (11 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 12/29] ui: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  8:37   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 14/29] virtio-gpu: " Marc-André Lureau
                   ` (16 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, peter.maydell, Marc-André Lureau

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/display/vga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/display/vga.c b/hw/display/vga.c
index 80508b83f4..286295272c 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -1621,7 +1621,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
            s->line_compare, sr(s, VGA_SEQ_CLOCK_MODE));
 #endif
     addr1 = (s->start_addr * 4);
-    bwidth = (width * bits + 7) / 8;
+    bwidth = DIV_ROUND_UP(width * bits, 8);
     y_start = -1;
     d = surface_data(surface);
     linesize = surface_stride(surface);
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 14/29] virtio-gpu: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (12 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 13/29] vga: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
  2017-07-14  8:37   ` [Qemu-devel] " Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 15/29] monitor: " Marc-André Lureau
                   ` (15 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Michael S. Tsirkin

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/display/virtio-gpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 0506d2c1b0..669f36f8bb 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -408,7 +408,7 @@ static void virtio_gpu_transfer_to_host_2d(VirtIOGPU *g,
     }
 
     format = pixman_image_get_format(res->image);
-    bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
+    bpp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
     stride = pixman_image_get_stride(res->image);
 
     if (t2d.offset || t2d.r.x || t2d.r.y ||
@@ -570,7 +570,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
     scanout = &g->scanout[ss.scanout_id];
 
     format = pixman_image_get_format(res->image);
-    bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
+    bpp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
     offset = (ss.r.x * bpp) + ss.r.y * pixman_image_get_stride(res->image);
     if (!scanout->ds || surface_data(scanout->ds)
         != ((uint8_t *)pixman_image_get_data(res->image) + offset) ||
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 15/29] monitor: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (13 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 14/29] virtio-gpu: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-13 17:12   ` Dr. David Alan Gilbert
  2017-07-14  8:38   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 16/29] console: " Marc-André Lureau
                   ` (14 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	Markus Armbruster, Dr. David Alan Gilbert

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 monitor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/monitor.c b/monitor.c
index fa3e3ac251..bcbf307b45 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1348,7 +1348,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
 
     switch(format) {
     case 'o':
-        max_digits = (wsize * 8 + 2) / 3;
+        max_digits = DIV_ROUND_UP(wsize * 8, 3);
         break;
     default:
     case 'x':
@@ -1356,7 +1356,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
         break;
     case 'u':
     case 'd':
-        max_digits = (wsize * 8 * 10 + 32) / 33;
+        max_digits = DIV_ROUND_UP(wsize * 8 * 10, 33);
         break;
     case 'c':
         wsize = 1;
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 16/29] console: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (14 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 15/29] monitor: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
  2017-07-14  8:38   ` [Qemu-devel] " Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 17/29] virtio-serial: " Marc-André Lureau
                   ` (13 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Gerd Hoffmann

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/ui/console.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 7262bef6d3..8024878bae 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -328,7 +328,7 @@ static inline int surface_bits_per_pixel(DisplaySurface *s)
 static inline int surface_bytes_per_pixel(DisplaySurface *s)
 {
     int bits = PIXMAN_FORMAT_BPP(s->format);
-    return (bits + 7) / 8;
+    return DIV_ROUND_UP(bits, 8);
 }
 
 static inline pixman_format_code_t surface_format(DisplaySurface *s)
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 17/29] virtio-serial: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (15 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 16/29] console: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  4:22   ` Philippe Mathieu-Daudé
                     ` (2 more replies)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 18/29] piix: " Marc-André Lureau
                   ` (12 subsequent siblings)
  29 siblings, 3 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Amit Shah,
	Michael S. Tsirkin, Paolo Bonzini

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/char/virtio-serial-bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index f5bc173844..17a1bb008a 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -663,7 +663,7 @@ static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f)
 
     /* The ports map */
     max_nr_ports = s->serial.max_virtserial_ports;
-    for (i = 0; i < (max_nr_ports + 31) / 32; i++) {
+    for (i = 0; i < DIV_ROUND_UP(max_nr_ports, 32); i++) {
         qemu_put_be32s(f, &s->ports_map[i]);
     }
 
@@ -798,7 +798,7 @@ static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f,
     qemu_get_be32s(f, &tmp);
 
     max_nr_ports = s->serial.max_virtserial_ports;
-    for (i = 0; i < (max_nr_ports + 31) / 32; i++) {
+    for (i = 0; i < DIV_ROUND_UP(max_nr_ports, 32); i++) {
         qemu_get_be32s(f, &ports_map);
 
         if (ports_map != s->ports_map[i]) {
@@ -863,7 +863,7 @@ static uint32_t find_free_port_id(VirtIOSerial *vser)
     unsigned int i, max_nr_ports;
 
     max_nr_ports = vser->serial.max_virtserial_ports;
-    for (i = 0; i < (max_nr_ports + 31) / 32; i++) {
+    for (i = 0; i < DIV_ROUND_UP(max_nr_ports, 32); i++) {
         uint32_t map, zeroes;
 
         map = vser->ports_map[i];
@@ -1075,7 +1075,7 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp)
         vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
     }
 
-    vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32)
+    vser->ports_map = g_malloc0((DIV_ROUND_UP(vser->serial.max_virtserial_ports, 32))
         * sizeof(vser->ports_map[0]));
     /*
      * Reserve location 0 for a console port for backward compat
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 18/29] piix: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (16 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 17/29] virtio-serial: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
  2017-07-14  8:39   ` [Qemu-devel] " Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 19/29] q35: " Marc-André Lureau
                   ` (11 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Michael S. Tsirkin

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/pci-host/piix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index a2c1033dbe..3745b56c8e 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -140,7 +140,7 @@ static void i440fx_update_memory_mappings(PCII440FXState *d)
     memory_region_transaction_begin();
     for (i = 0; i < 13; i++) {
         pam_update(&d->pam_regions[i], i,
-                   pd->config[I440FX_PAM + ((i + 1) / 2)]);
+                   pd->config[I440FX_PAM + (DIV_ROUND_UP(i, 2))]);
     }
     memory_region_set_enabled(&d->smram_region,
                               !(pd->config[I440FX_SMRAM] & SMRAM_D_OPEN));
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 19/29] q35: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (17 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 18/29] piix: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  8:39   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 20/29] usb-hub: " Marc-André Lureau
                   ` (10 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Michael S. Tsirkin

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/pci-host/q35.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 0e472f2ed4..1ff648e80c 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -315,7 +315,7 @@ static void mch_update_pam(MCHPCIState *mch)
     memory_region_transaction_begin();
     for (i = 0; i < 13; i++) {
         pam_update(&mch->pam_regions[i], i,
-                   pd->config[MCH_HOST_BRIDGE_PAM0 + ((i + 1) / 2)]);
+                   pd->config[MCH_HOST_BRIDGE_PAM0 + (DIV_ROUND_UP(i, 2))]);
     }
     memory_region_transaction_commit();
 }
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 20/29] usb-hub: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (18 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 19/29] q35: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  8:40   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 21/29] msix: " Marc-André Lureau
                   ` (9 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Gerd Hoffmann

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/usb/dev-hub.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index e82a6a6c44..752e30c305 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -109,7 +109,7 @@ static const USBDescIface desc_iface_hub = {
         {
             .bEndpointAddress      = USB_DIR_IN | 0x01,
             .bmAttributes          = USB_ENDPOINT_XFER_INT,
-            .wMaxPacketSize        = 1 + (NUM_PORTS + 7) / 8,
+            .wMaxPacketSize        = 1 + DIV_ROUND_UP(NUM_PORTS, 8),
             .bInterval             = 0xff,
         },
     }
@@ -442,14 +442,14 @@ static void usb_hub_handle_control(USBDevice *dev, USBPacket *p,
             data[2] = NUM_PORTS;
 
             /* fill DeviceRemovable bits */
-            limit = ((NUM_PORTS + 1 + 7) / 8) + 7;
+            limit = DIV_ROUND_UP(NUM_PORTS + 1, 8) + 7;
             for (n = 7; n < limit; n++) {
                 data[n] = 0x00;
                 var_hub_size++;
             }
 
             /* fill PortPwrCtrlMask bits */
-            limit = limit + ((NUM_PORTS + 7) / 8);
+            limit = limit + DIV_ROUND_UP(NUM_PORTS, 8);
             for (;n < limit; n++) {
                 data[n] = 0xff;
                 var_hub_size++;
@@ -477,7 +477,7 @@ static void usb_hub_handle_data(USBDevice *dev, USBPacket *p)
             unsigned int status;
             uint8_t buf[4];
             int i, n;
-            n = (NUM_PORTS + 1 + 7) / 8;
+            n = DIV_ROUND_UP(NUM_PORTS + 1, 8);
             if (p->iov.size == 1) { /* FreeBSD workaround */
                 n = 1;
             } else if (n > p->iov.size) {
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 21/29] msix: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (19 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 20/29] usb-hub: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  4:24   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
  2017-07-14  8:41   ` [Qemu-devel] " Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 22/29] ppc: " Marc-André Lureau
                   ` (8 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	Michael S. Tsirkin, Marcel Apfelbaum

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/pci/msix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index 5078d3dd19..c944c02135 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -438,7 +438,7 @@ void msix_save(PCIDevice *dev, QEMUFile *f)
     }
 
     qemu_put_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
-    qemu_put_buffer(f, dev->msix_pba, (n + 7) / 8);
+    qemu_put_buffer(f, dev->msix_pba, DIV_ROUND_UP(n, 8));
 }
 
 /* Should be called after restoring the config space. */
@@ -453,7 +453,7 @@ void msix_load(PCIDevice *dev, QEMUFile *f)
 
     msix_clear_all_vectors(dev);
     qemu_get_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
-    qemu_get_buffer(f, dev->msix_pba, (n + 7) / 8);
+    qemu_get_buffer(f, dev->msix_pba, DIV_ROUND_UP(n, 8));
     msix_update_function_masked(dev);
 
     for (vector = 0; vector < n; vector++) {
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 22/29] ppc: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (20 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 21/29] msix: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  8:41   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 23/29] i386/dump: " Marc-André Lureau
                   ` (7 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	David Gibson, Alexander Graf, open list:PowerPC

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
---
 target/ppc/mem_helper.c | 2 +-
 target/ppc/translate.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
index e6383c6bfa..a34e604db3 100644
--- a/target/ppc/mem_helper.c
+++ b/target/ppc/mem_helper.c
@@ -111,7 +111,7 @@ void helper_lswx(CPUPPCState *env, target_ulong addr, uint32_t reg,
                  uint32_t ra, uint32_t rb)
 {
     if (likely(xer_bc != 0)) {
-        int num_used_regs = (xer_bc + 3) / 4;
+        int num_used_regs = DIV_ROUND_UP(xer_bc, 4);
         if (unlikely((ra != 0 && lsw_reg_in_range(reg, num_used_regs, ra)) ||
                      lsw_reg_in_range(reg, num_used_regs, rb))) {
             raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index c0cd64d927..76f9ccde25 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -2882,7 +2882,7 @@ static void gen_lswi(DisasContext *ctx)
     }
     if (nb == 0)
         nb = 32;
-    nr = (nb + 3) / 4;
+    nr = DIV_ROUND_UP(nb, 4);
     if (unlikely(lsw_reg_in_range(start, nr, ra))) {
         gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
         return;
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 23/29] i386/dump: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (21 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 22/29] ppc: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-13 16:38   ` Eduardo Habkost
  2017-07-14  8:41   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 24/29] kvm: " Marc-André Lureau
                   ` (6 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	Paolo Bonzini, Richard Henderson, Eduardo Habkost

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 target/i386/arch_dump.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c
index 1d51bb5206..e081f677fa 100644
--- a/target/i386/arch_dump.c
+++ b/target/i386/arch_dump.c
@@ -77,8 +77,8 @@ static int x86_64_write_elf64_note(WriteCoreDumpFunction f,
     regs.gs = env->segs[R_GS].selector;
 
     descsz = sizeof(x86_64_elf_prstatus);
-    note_size = ((sizeof(Elf64_Nhdr) + 3) / 4 + (name_size + 3) / 4 +
-                (descsz + 3) / 4) * 4;
+    note_size = (DIV_ROUND_UP(sizeof(Elf64_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +
+                DIV_ROUND_UP(descsz, 4)) * 4;
     note = g_malloc0(note_size);
     note->n_namesz = cpu_to_le32(name_size);
     note->n_descsz = cpu_to_le32(descsz);
@@ -156,8 +156,8 @@ static int x86_write_elf64_note(WriteCoreDumpFunction f, CPUX86State *env,
 
     x86_fill_elf_prstatus(&prstatus, env, id);
     descsz = sizeof(x86_elf_prstatus);
-    note_size = ((sizeof(Elf64_Nhdr) + 3) / 4 + (name_size + 3) / 4 +
-                (descsz + 3) / 4) * 4;
+    note_size = (DIV_ROUND_UP(sizeof(Elf64_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +
+                DIV_ROUND_UP(descsz, 4)) * 4;
     note = g_malloc0(note_size);
     note->n_namesz = cpu_to_le32(name_size);
     note->n_descsz = cpu_to_le32(descsz);
@@ -211,8 +211,8 @@ int x86_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
 
     x86_fill_elf_prstatus(&prstatus, &cpu->env, cpuid);
     descsz = sizeof(x86_elf_prstatus);
-    note_size = ((sizeof(Elf32_Nhdr) + 3) / 4 + (name_size + 3) / 4 +
-                (descsz + 3) / 4) * 4;
+    note_size = (DIV_ROUND_UP(sizeof(Elf32_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +
+                DIV_ROUND_UP(descsz, 4)) * 4;
     note = g_malloc0(note_size);
     note->n_namesz = cpu_to_le32(name_size);
     note->n_descsz = cpu_to_le32(descsz);
@@ -338,8 +338,8 @@ static inline int cpu_write_qemu_note(WriteCoreDumpFunction f,
     } else {
         note_head_size = sizeof(Elf64_Nhdr);
     }
-    note_size = ((note_head_size + 3) / 4 + (name_size + 3) / 4 +
-                (descsz + 3) / 4) * 4;
+    note_size = (DIV_ROUND_UP(note_head_size, 4) + DIV_ROUND_UP(name_size, 4) +
+                DIV_ROUND_UP(descsz, 4)) * 4;
     note = g_malloc0(note_size);
     if (type == 0) {
         note32 = note;
@@ -443,10 +443,10 @@ ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)
 #endif
     qemu_desc_size = sizeof(QEMUCPUState);
 
-    elf_note_size = ((note_head_size + 3) / 4 + (name_size + 3) / 4 +
-                     (elf_desc_size + 3) / 4) * 4;
-    qemu_note_size = ((note_head_size + 3) / 4 + (name_size + 3) / 4 +
-                      (qemu_desc_size + 3) / 4) * 4;
+    elf_note_size = (DIV_ROUND_UP(note_head_size, 4) + DIV_ROUND_UP(name_size, 4) +
+                     DIV_ROUND_UP(elf_desc_size, 4)) * 4;
+    qemu_note_size = (DIV_ROUND_UP(note_head_size, 4) + DIV_ROUND_UP(name_size, 4) +
+                      DIV_ROUND_UP(qemu_desc_size, 4)) * 4;
 
     return (elf_note_size + qemu_note_size) * nr_cpus;
 }
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 24/29] kvm: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (22 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 23/29] i386/dump: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  8:42   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 25/29] decnumber: " Marc-André Lureau
                   ` (5 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, peter.maydell, Marc-André Lureau

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 linux-headers/asm-x86/kvm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
index c2824d02ba..1930b95bcb 100644
--- a/linux-headers/asm-x86/kvm.h
+++ b/linux-headers/asm-x86/kvm.h
@@ -153,7 +153,7 @@ struct kvm_sregs {
 	__u64 cr0, cr2, cr3, cr4, cr8;
 	__u64 efer;
 	__u64 apic_base;
-	__u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
+	__u64 interrupt_bitmap[DIV_ROUND_UP(KVM_NR_INTERRUPTS, 64)];
 };
 
 /* for KVM_GET_FPU and KVM_SET_FPU */
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 25/29] decnumber: use DIV_ROUND_UP
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (23 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 24/29] kvm: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  8:42   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 26/29] i386: introduce ELF_NOTE_SIZE macro Marc-André Lureau
                   ` (4 subsequent siblings)
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, peter.maydell, Marc-André Lureau

I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 libdecnumber/decNumber.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index c9e7807f87..8c197023f4 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -4775,7 +4775,7 @@ static decNumber * decDivideOp(decNumber *res,
 	    half=*up & 0x01;
 	    *up/=2;		   /* [shift] */
 	    if (!half) continue;
-	    *(up-1)+=(DECDPUNMAX+1)/2;
+	    *(up-1)+=DIV_ROUND_UP(DECDPUNMAX, 2);
 	    }
 	  /* [accunits still describes the original remainder length] */
 
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 26/29] i386: introduce ELF_NOTE_SIZE macro
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (24 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 25/29] decnumber: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-13 16:41   ` Eduardo Habkost
  2017-07-14  8:46   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 27/29] i386: replace g_malloc()+memcpy() with g_memdup() Marc-André Lureau
                   ` (3 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	Paolo Bonzini, Richard Henderson, Eduardo Habkost

Factour out a common pattern to compute the ELF note size.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 target/i386/arch_dump.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c
index e081f677fa..e682904052 100644
--- a/target/i386/arch_dump.c
+++ b/target/i386/arch_dump.c
@@ -18,6 +18,11 @@
 #include "elf.h"
 #include "sysemu/memory_mapping.h"
 
+#define ELF_NOTE_SIZE(hdr_size, name_size, desc_size)   \
+    ((DIV_ROUND_UP((hdr_size), 4)                       \
+      + DIV_ROUND_UP((name_size), 4)                    \
+      + DIV_ROUND_UP((desc_size), 4)) * 4)
+
 #ifdef TARGET_X86_64
 typedef struct {
     target_ulong r15, r14, r13, r12, rbp, rbx, r11, r10;
@@ -77,8 +82,7 @@ static int x86_64_write_elf64_note(WriteCoreDumpFunction f,
     regs.gs = env->segs[R_GS].selector;
 
     descsz = sizeof(x86_64_elf_prstatus);
-    note_size = (DIV_ROUND_UP(sizeof(Elf64_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +
-                DIV_ROUND_UP(descsz, 4)) * 4;
+    note_size = ELF_NOTE_SIZE(sizeof(Elf64_Nhdr), name_size, descsz);
     note = g_malloc0(note_size);
     note->n_namesz = cpu_to_le32(name_size);
     note->n_descsz = cpu_to_le32(descsz);
@@ -156,8 +160,7 @@ static int x86_write_elf64_note(WriteCoreDumpFunction f, CPUX86State *env,
 
     x86_fill_elf_prstatus(&prstatus, env, id);
     descsz = sizeof(x86_elf_prstatus);
-    note_size = (DIV_ROUND_UP(sizeof(Elf64_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +
-                DIV_ROUND_UP(descsz, 4)) * 4;
+    note_size = ELF_NOTE_SIZE(sizeof(Elf64_Nhdr), name_size, descsz);
     note = g_malloc0(note_size);
     note->n_namesz = cpu_to_le32(name_size);
     note->n_descsz = cpu_to_le32(descsz);
@@ -211,8 +214,7 @@ int x86_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
 
     x86_fill_elf_prstatus(&prstatus, &cpu->env, cpuid);
     descsz = sizeof(x86_elf_prstatus);
-    note_size = (DIV_ROUND_UP(sizeof(Elf32_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +
-                DIV_ROUND_UP(descsz, 4)) * 4;
+    note_size = ELF_NOTE_SIZE(sizeof(Elf32_Nhdr), name_size, descsz);
     note = g_malloc0(note_size);
     note->n_namesz = cpu_to_le32(name_size);
     note->n_descsz = cpu_to_le32(descsz);
@@ -443,10 +445,8 @@ ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)
 #endif
     qemu_desc_size = sizeof(QEMUCPUState);
 
-    elf_note_size = (DIV_ROUND_UP(note_head_size, 4) + DIV_ROUND_UP(name_size, 4) +
-                     DIV_ROUND_UP(elf_desc_size, 4)) * 4;
-    qemu_note_size = (DIV_ROUND_UP(note_head_size, 4) + DIV_ROUND_UP(name_size, 4) +
-                      DIV_ROUND_UP(qemu_desc_size, 4)) * 4;
+    elf_note_size = ELF_NOTE_SIZE(note_head_size, name_size, elf_desc_size);
+    qemu_note_size = ELF_NOTE_SIZE(note_head_size, name_size, qemu_desc_size);
 
     return (elf_note_size + qemu_note_size) * nr_cpus;
 }
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 27/29] i386: replace g_malloc()+memcpy() with g_memdup()
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (25 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 26/29] i386: introduce ELF_NOTE_SIZE macro Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-13 16:41   ` Eduardo Habkost
  2017-07-14  8:44   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 28/29] test-iov: " Marc-André Lureau
                   ` (2 subsequent siblings)
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau,
	Michael S. Tsirkin, Paolo Bonzini, Richard Henderson,
	Eduardo Habkost

I found these pattern via grepping the source tree. I don't have a
coccinelle script for it!

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/i386/multiboot.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index f13e23139b..6001f4caa2 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -352,8 +352,7 @@ int load_multiboot(FWCfgState *fw_cfg,
     mb_debug("           mb_mods_count = %d\n", mbs.mb_mods_count);
 
     /* save bootinfo off the stack */
-    mb_bootinfo_data = g_malloc(sizeof(bootinfo));
-    memcpy(mb_bootinfo_data, bootinfo, sizeof(bootinfo));
+    mb_bootinfo_data = g_memdup(bootinfo, sizeof(bootinfo));
 
     /* Pass variables to option rom */
     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ENTRY, mh_entry_addr);
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 28/29] test-iov: replace g_malloc()+memcpy() with g_memdup()
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (26 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 27/29] i386: replace g_malloc()+memcpy() with g_memdup() Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  4:27   ` Philippe Mathieu-Daudé
  2017-07-14  8:44   ` Richard Henderson
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 29/29] eepro100: " Marc-André Lureau
  2017-07-13 18:56 ` [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy no-reply
  29 siblings, 2 replies; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, peter.maydell, Marc-André Lureau

I found these pattern via grepping the source tree. I don't have a
coccinelle script for it!

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/test-iov.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/test-iov.c b/tests/test-iov.c
index a22d71fd2c..fa3d75aee1 100644
--- a/tests/test-iov.c
+++ b/tests/test-iov.c
@@ -167,8 +167,7 @@ static void test_io(void)
     }
     iov_from_buf(iov, niov, 0, buf, sz);
 
-    siov = g_malloc(sizeof(*iov) * niov);
-    memcpy(siov, iov, sizeof(*iov) * niov);
+    siov = g_memdup(iov, sizeof(*iov) * niov);
 
     if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) {
        perror("socketpair");
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Qemu-devel] [PATCH v2 29/29] eepro100: replace g_malloc()+memcpy() with g_memdup()
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (27 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 28/29] test-iov: " Marc-André Lureau
@ 2017-07-13 16:32 ` Marc-André Lureau
  2017-07-14  8:45   ` Richard Henderson
  2017-07-13 18:56 ` [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy no-reply
  29 siblings, 1 reply; 78+ messages in thread
From: Marc-André Lureau @ 2017-07-13 16:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, peter.maydell, Marc-André Lureau, Jason Wang

I found these pattern via grepping the source tree. I don't have a
coccinelle script for it!

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/eepro100.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index 5a4774aab4..a7b9f77519 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1904,8 +1904,7 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
 
     qemu_register_reset(nic_reset, s);
 
-    s->vmstate = g_malloc(sizeof(vmstate_eepro100));
-    memcpy(s->vmstate, &vmstate_eepro100, sizeof(vmstate_eepro100));
+    s->vmstate = g_memdup(&vmstate_eepro100, sizeof(vmstate_eepro100));
     s->vmstate->name = qemu_get_queue(s->nic)->model;
     vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);
 }
-- 
2.13.1.395.gf7b71de06

^ permalink raw reply related	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro Marc-André Lureau
@ 2017-07-13 16:35   ` Eduardo Habkost
  2017-07-14  8:10   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Eduardo Habkost @ 2017-07-13 16:35 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, qemu-trivial, peter.maydell, Paolo Bonzini,
	Richard Henderson

On Thu, Jul 13, 2017 at 06:31:51PM +0200, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check (with the option OnlyAlignUp)
> to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Juan Quintela <quintela@redhat.com>

Acked-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 23/29] i386/dump: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 23/29] i386/dump: " Marc-André Lureau
@ 2017-07-13 16:38   ` Eduardo Habkost
  2017-07-14  8:41   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Eduardo Habkost @ 2017-07-13 16:38 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, qemu-trivial, peter.maydell, Paolo Bonzini,
	Richard Henderson

On Thu, Jul 13, 2017 at 06:32:13PM +0200, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Acked-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 26/29] i386: introduce ELF_NOTE_SIZE macro
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 26/29] i386: introduce ELF_NOTE_SIZE macro Marc-André Lureau
@ 2017-07-13 16:41   ` Eduardo Habkost
  2017-07-14  8:46   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Eduardo Habkost @ 2017-07-13 16:41 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, qemu-trivial, peter.maydell, Paolo Bonzini,
	Richard Henderson

On Thu, Jul 13, 2017 at 06:32:16PM +0200, Marc-André Lureau wrote:
> Factour out a common pattern to compute the ELF note size.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 27/29] i386: replace g_malloc()+memcpy() with g_memdup()
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 27/29] i386: replace g_malloc()+memcpy() with g_memdup() Marc-André Lureau
@ 2017-07-13 16:41   ` Eduardo Habkost
  2017-07-14  8:44   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Eduardo Habkost @ 2017-07-13 16:41 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, qemu-trivial, peter.maydell, Michael S. Tsirkin,
	Paolo Bonzini, Richard Henderson

On Thu, Jul 13, 2017 at 06:32:17PM +0200, Marc-André Lureau wrote:
> I found these pattern via grepping the source tree. I don't have a
> coccinelle script for it!
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 15/29] monitor: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 15/29] monitor: " Marc-André Lureau
@ 2017-07-13 17:12   ` Dr. David Alan Gilbert
  2017-07-14  8:38   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Dr. David Alan Gilbert @ 2017-07-13 17:12 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, qemu-trivial, peter.maydell, Markus Armbruster

* Marc-André Lureau (marcandre.lureau@redhat.com) wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  monitor.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index fa3e3ac251..bcbf307b45 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1348,7 +1348,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
>  
>      switch(format) {
>      case 'o':
> -        max_digits = (wsize * 8 + 2) / 3;
> +        max_digits = DIV_ROUND_UP(wsize * 8, 3);
>          break;
>      default:
>      case 'x':
> @@ -1356,7 +1356,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
>          break;
>      case 'u':
>      case 'd':
> -        max_digits = (wsize * 8 * 10 + 32) / 33;
> +        max_digits = DIV_ROUND_UP(wsize * 8 * 10, 33);
>          break;
>      case 'c':
>          wsize = 1;
> -- 
> 2.13.1.395.gf7b71de06
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy
  2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
                   ` (28 preceding siblings ...)
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 29/29] eepro100: " Marc-André Lureau
@ 2017-07-13 18:56 ` no-reply
  29 siblings, 0 replies; 78+ messages in thread
From: no-reply @ 2017-07-13 18:56 UTC (permalink / raw)
  To: marcandre.lureau; +Cc: famz, qemu-devel, qemu-trivial, peter.maydell

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20170713163219.9024-1-marcandre.lureau@redhat.com
Subject: [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/20170713010555.6769-1-eblake@redhat.com -> patchew/20170713010555.6769-1-eblake@redhat.com
Switched to a new branch 'test'
2f7ac63 eepro100: replace g_malloc()+memcpy() with g_memdup()
3a8281d test-iov: replace g_malloc()+memcpy() with g_memdup()
3a0c841 i386: replace g_malloc()+memcpy() with g_memdup()
0b15a3c i386: introduce ELF_NOTE_SIZE macro
898ad06 decnumber: use DIV_ROUND_UP
53b41ec kvm: use DIV_ROUND_UP
b0f3ea1 i386/dump: use DIV_ROUND_UP
114596b ppc: use DIV_ROUND_UP
0bbd959 msix: use DIV_ROUND_UP
c79c77f usb-hub: use DIV_ROUND_UP
ae841af q35: use DIV_ROUND_UP
1cc1094 piix: use DIV_ROUND_UP
8994734 virtio-serial: use DIV_ROUND_UP
027155b console: use DIV_ROUND_UP
1870cdd monitor: use DIV_ROUND_UP
11b4eb8 virtio-gpu: use DIV_ROUND_UP
0e596e2 vga: use DIV_ROUND_UP
4e0dbf4 ui: use DIV_ROUND_UP
e9b6331 vnc: use DIV_ROUND_UP
821720e vvfat: use DIV_ROUND_UP
dc25074 vpc: use DIV_ROUND_UP
f157250 qcow2: use DIV_ROUND_UP
ad10be5 dmg: use DIV_ROUND_UP
4035ed7 pcspk: use QEMU_ALIGN_DOWN
e89654b i8254: use QEMU_ALIGN_DOWN
efc2b8b vhost: use QEMU_ALIGN_DOWN
ce3c657 vhdx: use QEMU_ALIGN_DOWN
7de432c vnc: use QEMU_ALIGN_DOWN
b116446 i386: use ROUND_UP macro

=== OUTPUT BEGIN ===
Checking PATCH 1/29: i386: use ROUND_UP macro...
Checking PATCH 2/29: vnc: use QEMU_ALIGN_DOWN...
Checking PATCH 3/29: vhdx: use QEMU_ALIGN_DOWN...
Checking PATCH 4/29: vhost: use QEMU_ALIGN_DOWN...
Checking PATCH 5/29: i8254: use QEMU_ALIGN_DOWN...
Checking PATCH 6/29: pcspk: use QEMU_ALIGN_DOWN...
ERROR: line over 90 characters
#24: FILE: hw/audio/pcspk.c:72:
+        s->samples = (QEMU_ALIGN_DOWN(PCSPK_BUF_LEN * PIT_FREQ, m) / (PIT_FREQ >> 1) + 1) >> 1;

total: 1 errors, 0 warnings, 8 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 7/29: dmg: use DIV_ROUND_UP...
Checking PATCH 8/29: qcow2: use DIV_ROUND_UP...
Checking PATCH 9/29: vpc: use DIV_ROUND_UP...
Checking PATCH 10/29: vvfat: use DIV_ROUND_UP...
ERROR: "(foo*)" should be "(foo *)"
#33: FILE: block/vvfat.c:2523:
+            (uint8_t*)cluster, DIV_ROUND_UP(rest_size, 0x200));

total: 1 errors, 0 warnings, 16 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 11/29: vnc: use DIV_ROUND_UP...
WARNING: line over 80 characters
#37: FILE: ui/vnc.c:2784:
+        guest_ll = pixman_image_get_width(vd->guest.fb) * (DIV_ROUND_UP(guest_bpp, 8));

total: 0 errors, 1 warnings, 16 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 12/29: ui: use DIV_ROUND_UP...
Checking PATCH 13/29: vga: use DIV_ROUND_UP...
Checking PATCH 14/29: virtio-gpu: use DIV_ROUND_UP...
Checking PATCH 15/29: monitor: use DIV_ROUND_UP...
Checking PATCH 16/29: console: use DIV_ROUND_UP...
Checking PATCH 17/29: virtio-serial: use DIV_ROUND_UP...
WARNING: line over 80 characters
#51: FILE: hw/char/virtio-serial-bus.c:1078:
+    vser->ports_map = g_malloc0((DIV_ROUND_UP(vser->serial.max_virtserial_ports, 32))

total: 0 errors, 1 warnings, 32 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 18/29: piix: use DIV_ROUND_UP...
Checking PATCH 19/29: q35: use DIV_ROUND_UP...
Checking PATCH 20/29: usb-hub: use DIV_ROUND_UP...
Checking PATCH 21/29: msix: use DIV_ROUND_UP...
Checking PATCH 22/29: ppc: use DIV_ROUND_UP...
Checking PATCH 23/29: i386/dump: use DIV_ROUND_UP...
WARNING: line over 80 characters
#26: FILE: target/i386/arch_dump.c:80:
+    note_size = (DIV_ROUND_UP(sizeof(Elf64_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +

WARNING: line over 80 characters
#37: FILE: target/i386/arch_dump.c:159:
+    note_size = (DIV_ROUND_UP(sizeof(Elf64_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +

WARNING: line over 80 characters
#48: FILE: target/i386/arch_dump.c:214:
+    note_size = (DIV_ROUND_UP(sizeof(Elf32_Nhdr), 4) + DIV_ROUND_UP(name_size, 4) +

WARNING: line over 80 characters
#72: FILE: target/i386/arch_dump.c:446:
+    elf_note_size = (DIV_ROUND_UP(note_head_size, 4) + DIV_ROUND_UP(name_size, 4) +

WARNING: line over 80 characters
#74: FILE: target/i386/arch_dump.c:448:
+    qemu_note_size = (DIV_ROUND_UP(note_head_size, 4) + DIV_ROUND_UP(name_size, 4) +

total: 0 errors, 5 warnings, 54 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 24/29: kvm: use DIV_ROUND_UP...
Checking PATCH 25/29: decnumber: use DIV_ROUND_UP...
ERROR: code indent should never use tabs
#24: FILE: libdecnumber/decNumber.c:4778:
+^I    *(up-1)+=DIV_ROUND_UP(DECDPUNMAX, 2);$

ERROR: spaces required around that '-' (ctx:VxV)
#24: FILE: libdecnumber/decNumber.c:4778:
+	    *(up-1)+=DIV_ROUND_UP(DECDPUNMAX, 2);
 	        ^

ERROR: spaces required around that '+=' (ctx:VxV)
#24: FILE: libdecnumber/decNumber.c:4778:
+	    *(up-1)+=DIV_ROUND_UP(DECDPUNMAX, 2);
 	           ^

total: 3 errors, 0 warnings, 8 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 26/29: i386: introduce ELF_NOTE_SIZE macro...
Checking PATCH 27/29: i386: replace g_malloc()+memcpy() with g_memdup()...
Checking PATCH 28/29: test-iov: replace g_malloc()+memcpy() with g_memdup()...
Checking PATCH 29/29: eepro100: replace g_malloc()+memcpy() with g_memdup()...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 03/29] vhdx: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 03/29] vhdx: " Marc-André Lureau
@ 2017-07-13 20:19   ` Eric Blake
  2017-07-14  8:11   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Eric Blake @ 2017-07-13 20:19 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:VHDX, qemu-trivial,
	Jeff Cody, Max Reitz

[-- Attachment #1: Type: text/plain, Size: 999 bytes --]

On 07/13/2017 11:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  block/vhdx-log.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/vhdx-log.c b/block/vhdx-log.c
> index 01278f3fc9..ad70706b99 100644
> --- a/block/vhdx-log.c
> +++ b/block/vhdx-log.c
> @@ -884,7 +884,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s,
>      }
>  
>      sector_offset = offset % VHDX_LOG_SECTOR_SIZE;
> -    file_offset = (offset / VHDX_LOG_SECTOR_SIZE) * VHDX_LOG_SECTOR_SIZE;
> +    file_offset = QEMU_ALIGN_DOWN(offset, VHDX_LOG_SECTOR_SIZE);
>  
>      aligned_length = length;
>  
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 08/29] qcow2: use DIV_ROUND_UP
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 08/29] qcow2: " Marc-André Lureau
@ 2017-07-13 20:20   ` Eric Blake
  2017-07-14  8:32   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Eric Blake @ 2017-07-13 20:20 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:qcow2, qemu-trivial, Max Reitz

[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]

On 07/13/2017 11:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  block/qcow2-cluster.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index f06c08f64c..30db942dde 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -61,7 +61,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
>              new_l1_size = 1;
>          }
>          while (min_size > new_l1_size) {
> -            new_l1_size = (new_l1_size * 3 + 1) / 2;
> +            new_l1_size = DIV_ROUND_UP(new_l1_size * 3, 2);
>          }
>      }
>  
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 09/29] vpc: use DIV_ROUND_UP
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 09/29] vpc: " Marc-André Lureau
@ 2017-07-13 20:20   ` Eric Blake
  2017-07-14  8:34   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Eric Blake @ 2017-07-13 20:20 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:vpc, qemu-trivial, Max Reitz

[-- Attachment #1: Type: text/plain, Size: 1406 bytes --]

On 07/13/2017 11:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  block/vpc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/vpc.c b/block/vpc.c
> index 9a6f8173a5..c88dc72491 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -760,7 +760,7 @@ static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
>      } else {
>          *secs_per_cyl = 17;
>          cyls_times_heads = total_sectors / *secs_per_cyl;
> -        *heads = (cyls_times_heads + 1023) / 1024;
> +        *heads = DIV_ROUND_UP(cyls_times_heads, 1024);
>  
>          if (*heads < 4) {
>              *heads = 4;
> @@ -813,7 +813,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
>      offset = 3 * 512;
>  
>      memset(buf, 0xFF, 512);
> -    for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) {
> +    for (i = 0; i < DIV_ROUND_UP(num_bat_entries * 4, 512); i++) {
>          ret = blk_pwrite(blk, offset, buf, 512, 0);
>          if (ret < 0) {
>              goto fail;
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 10/29] vvfat: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 10/29] vvfat: " Marc-André Lureau
@ 2017-07-13 20:21   ` Eric Blake
  2017-07-14  8:35   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Eric Blake @ 2017-07-13 20:21 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:vvfat, qemu-trivial, Max Reitz

[-- Attachment #1: Type: text/plain, Size: 954 bytes --]

On 07/13/2017 11:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  block/vvfat.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/vvfat.c b/block/vvfat.c
> index 4fd28e1e87..c08c4fb525 100644
> --- a/block/vvfat.c
> +++ b/block/vvfat.c
> @@ -437,7 +437,7 @@ static direntry_t *create_long_filename(BDRVVVFATState *s, const char *filename)
>          return NULL;
>      }
>  
> -    number_of_entries = (length * 2 + 25) / 26;
> +    number_of_entries = DIV_ROUND_UP(length * 2, 26);

Wow - a non-power-of-2!  Good thing our macro works for that.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 05/29] i8254: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 05/29] i8254: " Marc-André Lureau
@ 2017-07-14  4:17   ` Philippe Mathieu-Daudé
  2017-07-14  8:12   ` [Qemu-devel] " Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  4:17 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin, Paolo Bonzini

On 07/13/2017 01:31 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   hw/timer/i8254_common.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
> index 976d5200f1..ee064aa819 100644
> --- a/hw/timer/i8254_common.c
> +++ b/hw/timer/i8254_common.c
> @@ -93,7 +93,7 @@ int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time)
>           }
>           break;
>       case 2:
> -        base = (d / s->count) * s->count;
> +        base = QEMU_ALIGN_DOWN(d, s->count);
>           if ((d - base) == 0 && d != 0) {
>               next_time = base + s->count;
>           } else {
> @@ -101,7 +101,7 @@ int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time)
>           }
>           break;
>       case 3:
> -        base = (d / s->count) * s->count;
> +        base = QEMU_ALIGN_DOWN(d, s->count);
>           period2 = ((s->count + 1) >> 1);
>           if ((d - base) < period2) {
>               next_time = base + period2;
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 17/29] virtio-serial: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 17/29] virtio-serial: " Marc-André Lureau
@ 2017-07-14  4:22   ` Philippe Mathieu-Daudé
  2017-07-14  8:39   ` Richard Henderson
  2017-07-16 19:45   ` Amit Shah
  2 siblings, 0 replies; 78+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  4:22 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: peter.maydell, Amit Shah, qemu-trivial, Michael S. Tsirkin,
	Paolo Bonzini

On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   hw/char/virtio-serial-bus.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index f5bc173844..17a1bb008a 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -663,7 +663,7 @@ static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f)
>   
>       /* The ports map */
>       max_nr_ports = s->serial.max_virtserial_ports;
> -    for (i = 0; i < (max_nr_ports + 31) / 32; i++) {
> +    for (i = 0; i < DIV_ROUND_UP(max_nr_ports, 32); i++) {
>           qemu_put_be32s(f, &s->ports_map[i]);
>       }
>   
> @@ -798,7 +798,7 @@ static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f,
>       qemu_get_be32s(f, &tmp);
>   
>       max_nr_ports = s->serial.max_virtserial_ports;
> -    for (i = 0; i < (max_nr_ports + 31) / 32; i++) {
> +    for (i = 0; i < DIV_ROUND_UP(max_nr_ports, 32); i++) {
>           qemu_get_be32s(f, &ports_map);
>   
>           if (ports_map != s->ports_map[i]) {
> @@ -863,7 +863,7 @@ static uint32_t find_free_port_id(VirtIOSerial *vser)
>       unsigned int i, max_nr_ports;
>   
>       max_nr_ports = vser->serial.max_virtserial_ports;
> -    for (i = 0; i < (max_nr_ports + 31) / 32; i++) {
> +    for (i = 0; i < DIV_ROUND_UP(max_nr_ports, 32); i++) {
>           uint32_t map, zeroes;
>   
>           map = vser->ports_map[i];
> @@ -1075,7 +1075,7 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp)
>           vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
>       }
>   
> -    vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32)
> +    vser->ports_map = g_malloc0((DIV_ROUND_UP(vser->serial.max_virtserial_ports, 32))
>           * sizeof(vser->ports_map[0]));

This line seems quite long now

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>       /*
>        * Reserve location 0 for a console port for backward compat
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 16/29] console: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 16/29] console: " Marc-André Lureau
@ 2017-07-14  4:23   ` Philippe Mathieu-Daudé
  2017-07-14  8:38   ` [Qemu-devel] " Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  4:23 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Gerd Hoffmann

On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   include/ui/console.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/ui/console.h b/include/ui/console.h
> index 7262bef6d3..8024878bae 100644
> --- a/include/ui/console.h
> +++ b/include/ui/console.h
> @@ -328,7 +328,7 @@ static inline int surface_bits_per_pixel(DisplaySurface *s)
>   static inline int surface_bytes_per_pixel(DisplaySurface *s)
>   {
>       int bits = PIXMAN_FORMAT_BPP(s->format);
> -    return (bits + 7) / 8;
> +    return DIV_ROUND_UP(bits, 8);
>   }
>   
>   static inline pixman_format_code_t surface_format(DisplaySurface *s)
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 14/29] virtio-gpu: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 14/29] virtio-gpu: " Marc-André Lureau
@ 2017-07-14  4:23   ` Philippe Mathieu-Daudé
  2017-07-14  8:37   ` [Qemu-devel] " Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  4:23 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin

On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   hw/display/virtio-gpu.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 0506d2c1b0..669f36f8bb 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -408,7 +408,7 @@ static void virtio_gpu_transfer_to_host_2d(VirtIOGPU *g,
>       }
>   
>       format = pixman_image_get_format(res->image);
> -    bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
> +    bpp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
>       stride = pixman_image_get_stride(res->image);
>   
>       if (t2d.offset || t2d.r.x || t2d.r.y ||
> @@ -570,7 +570,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
>       scanout = &g->scanout[ss.scanout_id];
>   
>       format = pixman_image_get_format(res->image);
> -    bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
> +    bpp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
>       offset = (ss.r.x * bpp) + ss.r.y * pixman_image_get_stride(res->image);
>       if (!scanout->ds || surface_data(scanout->ds)
>           != ((uint8_t *)pixman_image_get_data(res->image) + offset) ||
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 12/29] ui: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 12/29] ui: " Marc-André Lureau
@ 2017-07-14  4:23   ` Philippe Mathieu-Daudé
  2017-07-14  8:36   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  4:23 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Gerd Hoffmann

On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   ui/cursor.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ui/cursor.c b/ui/cursor.c
> index 5155b392e8..2e2fe13fa6 100644
> --- a/ui/cursor.c
> +++ b/ui/cursor.c
> @@ -118,7 +118,7 @@ void cursor_put(QEMUCursor *c)
>   
>   int cursor_get_mono_bpl(QEMUCursor *c)
>   {
> -    return (c->width + 7) / 8;
> +    return DIV_ROUND_UP(c->width, 8);
>   }
>   
>   void cursor_set_mono(QEMUCursor *c,
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 18/29] piix: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 18/29] piix: " Marc-André Lureau
@ 2017-07-14  4:23   ` Philippe Mathieu-Daudé
  2017-07-14  8:39   ` [Qemu-devel] " Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  4:23 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin

On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   hw/pci-host/piix.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index a2c1033dbe..3745b56c8e 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -140,7 +140,7 @@ static void i440fx_update_memory_mappings(PCII440FXState *d)
>       memory_region_transaction_begin();
>       for (i = 0; i < 13; i++) {
>           pam_update(&d->pam_regions[i], i,
> -                   pd->config[I440FX_PAM + ((i + 1) / 2)]);
> +                   pd->config[I440FX_PAM + (DIV_ROUND_UP(i, 2))]);
>       }
>       memory_region_set_enabled(&d->smram_region,
>                                 !(pd->config[I440FX_SMRAM] & SMRAM_D_OPEN));
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 21/29] msix: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 21/29] msix: " Marc-André Lureau
@ 2017-07-14  4:24   ` Philippe Mathieu-Daudé
  2017-07-14  8:41   ` [Qemu-devel] " Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  4:24 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin, Marcel Apfelbaum

On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   hw/pci/msix.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci/msix.c b/hw/pci/msix.c
> index 5078d3dd19..c944c02135 100644
> --- a/hw/pci/msix.c
> +++ b/hw/pci/msix.c
> @@ -438,7 +438,7 @@ void msix_save(PCIDevice *dev, QEMUFile *f)
>       }
>   
>       qemu_put_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
> -    qemu_put_buffer(f, dev->msix_pba, (n + 7) / 8);
> +    qemu_put_buffer(f, dev->msix_pba, DIV_ROUND_UP(n, 8));
>   }
>   
>   /* Should be called after restoring the config space. */
> @@ -453,7 +453,7 @@ void msix_load(PCIDevice *dev, QEMUFile *f)
>   
>       msix_clear_all_vectors(dev);
>       qemu_get_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
> -    qemu_get_buffer(f, dev->msix_pba, (n + 7) / 8);
> +    qemu_get_buffer(f, dev->msix_pba, DIV_ROUND_UP(n, 8));
>       msix_update_function_masked(dev);
>   
>       for (vector = 0; vector < n; vector++) {
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 28/29] test-iov: replace g_malloc()+memcpy() with g_memdup()
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 28/29] test-iov: " Marc-André Lureau
@ 2017-07-14  4:27   ` Philippe Mathieu-Daudé
  2017-07-14  8:44   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  4:27 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: qemu-trivial, peter.maydell

On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I found these pattern via grepping the source tree. I don't have a
> coccinelle script for it!
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   tests/test-iov.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tests/test-iov.c b/tests/test-iov.c
> index a22d71fd2c..fa3d75aee1 100644
> --- a/tests/test-iov.c
> +++ b/tests/test-iov.c
> @@ -167,8 +167,7 @@ static void test_io(void)
>       }
>       iov_from_buf(iov, niov, 0, buf, sz);
>   
> -    siov = g_malloc(sizeof(*iov) * niov);
> -    memcpy(siov, iov, sizeof(*iov) * niov);
> +    siov = g_memdup(iov, sizeof(*iov) * niov);
>   
>       if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) {
>          perror("socketpair");
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro Marc-André Lureau
  2017-07-13 16:35   ` Eduardo Habkost
@ 2017-07-14  8:10   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:10 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: peter.maydell, Eduardo Habkost, qemu-trivial, Paolo Bonzini

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check (with the option OnlyAlignUp)
> to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> Reviewed-by: Juan Quintela<quintela@redhat.com>
> ---
>   target/i386/arch_dump.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 02/29] vnc: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 02/29] vnc: use QEMU_ALIGN_DOWN Marc-André Lureau
@ 2017-07-14  8:11   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:11 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Gerd Hoffmann

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   ui/vnc.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 03/29] vhdx: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 03/29] vhdx: " Marc-André Lureau
  2017-07-13 20:19   ` Eric Blake
@ 2017-07-14  8:11   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:11 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:VHDX, qemu-trivial,
	Jeff Cody, Max Reitz

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   block/vhdx-log.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 04/29] vhost: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 04/29] vhost: " Marc-André Lureau
@ 2017-07-14  8:12   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:12 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> Reviewed-by: Michael S. Tsirkin<mst@redhat.com>
> ---
>   hw/virtio/vhost.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 05/29] i8254: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 05/29] i8254: " Marc-André Lureau
  2017-07-14  4:17   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
@ 2017-07-14  8:12   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:12 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin, Paolo Bonzini

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/timer/i8254_common.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 06/29] pcspk: use QEMU_ALIGN_DOWN
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 06/29] pcspk: " Marc-André Lureau
@ 2017-07-14  8:29   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:29 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Gerd Hoffmann

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> -        s->samples = (PCSPK_BUF_LEN * PIT_FREQ / m * m / (PIT_FREQ >> 1) + 1) >> 1;
> +        s->samples = (QEMU_ALIGN_DOWN(PCSPK_BUF_LEN * PIT_FREQ, m) / (PIT_FREQ >> 1) + 1) >> 1;

Wow.  Um.  Two divisions?

Irritatingly, "m" appears to be the only non-constant.

This a true and correct conversion, so

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 07/29] dmg: use DIV_ROUND_UP
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 07/29] dmg: use DIV_ROUND_UP Marc-André Lureau
@ 2017-07-14  8:31   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:31 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:dmg, qemu-trivial,
	Max Reitz, Stefan Hajnoczi

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> Reviewed-by: Stefan Hajnoczi<stefanha@redhat.com>
> ---
>   block/dmg.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 08/29] qcow2: use DIV_ROUND_UP
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 08/29] qcow2: " Marc-André Lureau
  2017-07-13 20:20   ` Eric Blake
@ 2017-07-14  8:32   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:32 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:qcow2, qemu-trivial, Max Reitz

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   block/qcow2-cluster.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 09/29] vpc: use DIV_ROUND_UP
  2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 09/29] vpc: " Marc-André Lureau
  2017-07-13 20:20   ` Eric Blake
@ 2017-07-14  8:34   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:34 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:vpc, qemu-trivial, Max Reitz

On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   block/vpc.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 10/29] vvfat: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 10/29] vvfat: " Marc-André Lureau
  2017-07-13 20:21   ` Eric Blake
@ 2017-07-14  8:35   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:35 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: Kevin Wolf, peter.maydell, open list:vvfat, qemu-trivial, Max Reitz

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   block/vvfat.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 11/29] vnc: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 11/29] vnc: " Marc-André Lureau
@ 2017-07-14  8:36   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:36 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Gerd Hoffmann

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   ui/vnc-enc-tight.c | 2 +-
>   ui/vnc.c           | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 12/29] ui: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 12/29] ui: " Marc-André Lureau
  2017-07-14  4:23   ` Philippe Mathieu-Daudé
@ 2017-07-14  8:36   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:36 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Gerd Hoffmann

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   ui/cursor.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 13/29] vga: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 13/29] vga: " Marc-André Lureau
@ 2017-07-14  8:37   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:37 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: qemu-trivial, peter.maydell

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/display/vga.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 14/29] virtio-gpu: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 14/29] virtio-gpu: " Marc-André Lureau
  2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
@ 2017-07-14  8:37   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:37 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/display/virtio-gpu.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 15/29] monitor: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 15/29] monitor: " Marc-André Lureau
  2017-07-13 17:12   ` Dr. David Alan Gilbert
@ 2017-07-14  8:38   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:38 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Markus Armbruster, Dr. David Alan Gilbert

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   monitor.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 16/29] console: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 16/29] console: " Marc-André Lureau
  2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
@ 2017-07-14  8:38   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:38 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Gerd Hoffmann

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   include/ui/console.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 17/29] virtio-serial: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 17/29] virtio-serial: " Marc-André Lureau
  2017-07-14  4:22   ` Philippe Mathieu-Daudé
@ 2017-07-14  8:39   ` Richard Henderson
  2017-07-16 19:45   ` Amit Shah
  2 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:39 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: peter.maydell, Amit Shah, qemu-trivial, Michael S. Tsirkin,
	Paolo Bonzini

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/char/virtio-serial-bus.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 18/29] piix: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 18/29] piix: " Marc-André Lureau
  2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
@ 2017-07-14  8:39   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:39 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/pci-host/piix.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 19/29] q35: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 19/29] q35: " Marc-André Lureau
@ 2017-07-14  8:39   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:39 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/pci-host/q35.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 20/29] usb-hub: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 20/29] usb-hub: " Marc-André Lureau
@ 2017-07-14  8:40   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:40 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Gerd Hoffmann

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/usb/dev-hub.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 21/29] msix: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 21/29] msix: " Marc-André Lureau
  2017-07-14  4:24   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
@ 2017-07-14  8:41   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:41 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Michael S. Tsirkin, Marcel Apfelbaum

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/pci/msix.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 22/29] ppc: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 22/29] ppc: " Marc-André Lureau
@ 2017-07-14  8:41   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:41 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: peter.maydell, qemu-trivial, Alexander Graf, open list:PowerPC,
	David Gibson

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> Acked-by: David Gibson<david@gibson.dropbear.id.au>
> ---
>   target/ppc/mem_helper.c | 2 +-
>   target/ppc/translate.c  | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 23/29] i386/dump: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 23/29] i386/dump: " Marc-André Lureau
  2017-07-13 16:38   ` Eduardo Habkost
@ 2017-07-14  8:41   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:41 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: peter.maydell, Eduardo Habkost, qemu-trivial, Paolo Bonzini

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   target/i386/arch_dump.c | 24 ++++++++++++------------
>   1 file changed, 12 insertions(+), 12 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 24/29] kvm: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 24/29] kvm: " Marc-André Lureau
@ 2017-07-14  8:42   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:42 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: qemu-trivial, peter.maydell

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   linux-headers/asm-x86/kvm.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 25/29] decnumber: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 25/29] decnumber: " Marc-André Lureau
@ 2017-07-14  8:42   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:42 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: qemu-trivial, peter.maydell

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   libdecnumber/decNumber.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 27/29] i386: replace g_malloc()+memcpy() with g_memdup()
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 27/29] i386: replace g_malloc()+memcpy() with g_memdup() Marc-André Lureau
  2017-07-13 16:41   ` Eduardo Habkost
@ 2017-07-14  8:44   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:44 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: peter.maydell, Eduardo Habkost, Michael S. Tsirkin, qemu-trivial,
	Paolo Bonzini

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I found these pattern via grepping the source tree. I don't have a
> coccinelle script for it!
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/i386/multiboot.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 28/29] test-iov: replace g_malloc()+memcpy() with g_memdup()
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 28/29] test-iov: " Marc-André Lureau
  2017-07-14  4:27   ` Philippe Mathieu-Daudé
@ 2017-07-14  8:44   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:44 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: qemu-trivial, peter.maydell

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I found these pattern via grepping the source tree. I don't have a
> coccinelle script for it!
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   tests/test-iov.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 29/29] eepro100: replace g_malloc()+memcpy() with g_memdup()
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 29/29] eepro100: " Marc-André Lureau
@ 2017-07-14  8:45   ` Richard Henderson
  0 siblings, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:45 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: qemu-trivial, peter.maydell, Jason Wang

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I found these pattern via grepping the source tree. I don't have a
> coccinelle script for it!
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> Reviewed-by: Stefan Weil<sw@weilnetz.de>
> Reviewed-by: Jason Wang<jasowang@redhat.com>
> ---
>   hw/net/eepro100.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 26/29] i386: introduce ELF_NOTE_SIZE macro
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 26/29] i386: introduce ELF_NOTE_SIZE macro Marc-André Lureau
  2017-07-13 16:41   ` Eduardo Habkost
@ 2017-07-14  8:46   ` Richard Henderson
  1 sibling, 0 replies; 78+ messages in thread
From: Richard Henderson @ 2017-07-14  8:46 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel
  Cc: peter.maydell, Eduardo Habkost, qemu-trivial, Paolo Bonzini

On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> Factour out a common pattern to compute the ELF note size.
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   target/i386/arch_dump.c | 20 ++++++++++----------
>   1 file changed, 10 insertions(+), 10 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Qemu-devel] [PATCH v2 17/29] virtio-serial: use DIV_ROUND_UP
  2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 17/29] virtio-serial: " Marc-André Lureau
  2017-07-14  4:22   ` Philippe Mathieu-Daudé
  2017-07-14  8:39   ` Richard Henderson
@ 2017-07-16 19:45   ` Amit Shah
  2 siblings, 0 replies; 78+ messages in thread
From: Amit Shah @ 2017-07-16 19:45 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, qemu-trivial, peter.maydell, Amit Shah,
	Michael S. Tsirkin, Paolo Bonzini

On (Thu) 13 Jul 2017 [18:32:07], Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Amit Shah <amit@kernel.org>

		Amit
-- 
http://log.amitshah.net/

^ permalink raw reply	[flat|nested] 78+ messages in thread

end of thread, other threads:[~2017-07-16 19:45 UTC | newest]

Thread overview: 78+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 16:31 [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy Marc-André Lureau
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 01/29] i386: use ROUND_UP macro Marc-André Lureau
2017-07-13 16:35   ` Eduardo Habkost
2017-07-14  8:10   ` Richard Henderson
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 02/29] vnc: use QEMU_ALIGN_DOWN Marc-André Lureau
2017-07-14  8:11   ` Richard Henderson
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 03/29] vhdx: " Marc-André Lureau
2017-07-13 20:19   ` Eric Blake
2017-07-14  8:11   ` Richard Henderson
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 04/29] vhost: " Marc-André Lureau
2017-07-14  8:12   ` Richard Henderson
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 05/29] i8254: " Marc-André Lureau
2017-07-14  4:17   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
2017-07-14  8:12   ` [Qemu-devel] " Richard Henderson
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 06/29] pcspk: " Marc-André Lureau
2017-07-14  8:29   ` Richard Henderson
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 07/29] dmg: use DIV_ROUND_UP Marc-André Lureau
2017-07-14  8:31   ` Richard Henderson
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 08/29] qcow2: " Marc-André Lureau
2017-07-13 20:20   ` Eric Blake
2017-07-14  8:32   ` Richard Henderson
2017-07-13 16:31 ` [Qemu-devel] [PATCH v2 09/29] vpc: " Marc-André Lureau
2017-07-13 20:20   ` Eric Blake
2017-07-14  8:34   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 10/29] vvfat: " Marc-André Lureau
2017-07-13 20:21   ` Eric Blake
2017-07-14  8:35   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 11/29] vnc: " Marc-André Lureau
2017-07-14  8:36   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 12/29] ui: " Marc-André Lureau
2017-07-14  4:23   ` Philippe Mathieu-Daudé
2017-07-14  8:36   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 13/29] vga: " Marc-André Lureau
2017-07-14  8:37   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 14/29] virtio-gpu: " Marc-André Lureau
2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
2017-07-14  8:37   ` [Qemu-devel] " Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 15/29] monitor: " Marc-André Lureau
2017-07-13 17:12   ` Dr. David Alan Gilbert
2017-07-14  8:38   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 16/29] console: " Marc-André Lureau
2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
2017-07-14  8:38   ` [Qemu-devel] " Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 17/29] virtio-serial: " Marc-André Lureau
2017-07-14  4:22   ` Philippe Mathieu-Daudé
2017-07-14  8:39   ` Richard Henderson
2017-07-16 19:45   ` Amit Shah
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 18/29] piix: " Marc-André Lureau
2017-07-14  4:23   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
2017-07-14  8:39   ` [Qemu-devel] " Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 19/29] q35: " Marc-André Lureau
2017-07-14  8:39   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 20/29] usb-hub: " Marc-André Lureau
2017-07-14  8:40   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 21/29] msix: " Marc-André Lureau
2017-07-14  4:24   ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
2017-07-14  8:41   ` [Qemu-devel] " Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 22/29] ppc: " Marc-André Lureau
2017-07-14  8:41   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 23/29] i386/dump: " Marc-André Lureau
2017-07-13 16:38   ` Eduardo Habkost
2017-07-14  8:41   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 24/29] kvm: " Marc-André Lureau
2017-07-14  8:42   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 25/29] decnumber: " Marc-André Lureau
2017-07-14  8:42   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 26/29] i386: introduce ELF_NOTE_SIZE macro Marc-André Lureau
2017-07-13 16:41   ` Eduardo Habkost
2017-07-14  8:46   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 27/29] i386: replace g_malloc()+memcpy() with g_memdup() Marc-André Lureau
2017-07-13 16:41   ` Eduardo Habkost
2017-07-14  8:44   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 28/29] test-iov: " Marc-André Lureau
2017-07-14  4:27   ` Philippe Mathieu-Daudé
2017-07-14  8:44   ` Richard Henderson
2017-07-13 16:32 ` [Qemu-devel] [PATCH v2 29/29] eepro100: " Marc-André Lureau
2017-07-14  8:45   ` Richard Henderson
2017-07-13 18:56 ` [Qemu-devel] [PATCH v2 00/29] Refactoring with clang-tidy no-reply

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.