[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 23/29] i386/dump: use DIV_ROUND_UP
From: |
Marc-André Lureau |
Subject: |
[Qemu-trivial] [PULL 23/29] i386/dump: use DIV_ROUND_UP |
Date: |
Thu, 31 Aug 2017 12:34:26 +0200 |
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 <address@hidden>
Acked-by: Eduardo Habkost <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
---
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.14.1.146.gd35faa819
- [Qemu-trivial] [PULL 13/29] vga: use DIV_ROUND_UP, (continued)
- [Qemu-trivial] [PULL 13/29] vga: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 14/29] virtio-gpu: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 15/29] monitor: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 16/29] console: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 17/29] virtio-serial: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 18/29] piix: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 19/29] q35: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 20/29] usb-hub: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 21/29] msix: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 22/29] ppc: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 23/29] i386/dump: use DIV_ROUND_UP,
Marc-André Lureau <=
- [Qemu-trivial] [PULL 25/29] decnumber: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 24/29] kvm: use DIV_ROUND_UP, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 26/29] i386: introduce ELF_NOTE_SIZE macro, Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 27/29] i386: replace g_malloc()+memcpy() with g_memdup(), Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 29/29] eepro100: replace g_malloc()+memcpy() with g_memdup(), Marc-André Lureau, 2017/08/31
- [Qemu-trivial] [PULL 28/29] test-iov: replace g_malloc()+memcpy() with g_memdup(), Marc-André Lureau, 2017/08/31
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/29] Code cleanup patches, no-reply, 2017/08/31
- Re: [Qemu-trivial] [PULL 00/29] Code cleanup patches, Peter Maydell, 2017/08/31