[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 00/31] Refactoring with clang-tidy
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 00/31] Refactoring with clang-tidy |
Date: |
Thu, 22 Jun 2017 14:41:33 +0200 |
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.
Thanks
Marc-André Lureau (31):
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
slirp: 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
9pfs: replace g_malloc()+memcpy() with g_memdup()
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 +-
slirp/ip6.h | 6 +++---
block/dmg.c | 2 +-
block/qcow2-cluster.c | 2 +-
block/qcow2-refcount.c | 2 +-
block/vhdx-log.c | 2 +-
block/vpc.c | 4 ++--
block/vvfat.c | 4 ++--
hw/9pfs/9p-synth.c | 3 +--
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 +++++-----
31 files changed, 68 insertions(+), 72 deletions(-)
--
2.13.1.395.gf7b71de06
- [Qemu-devel] [PATCH 00/31] Refactoring with clang-tidy,
Marc-André Lureau <=
- [Qemu-devel] [PATCH 01/31] i386: use ROUND_UP macro, Marc-André Lureau, 2017/06/22
- [Qemu-devel] [PATCH 02/31] vnc: use QEMU_ALIGN_DOWN, Marc-André Lureau, 2017/06/22
- [Qemu-devel] [PATCH 03/31] vhdx: use QEMU_ALIGN_DOWN, Marc-André Lureau, 2017/06/22
- [Qemu-devel] [PATCH 04/31] vhost: use QEMU_ALIGN_DOWN, Marc-André Lureau, 2017/06/22
- [Qemu-devel] [PATCH 05/31] i8254: use QEMU_ALIGN_DOWN, Marc-André Lureau, 2017/06/22
- [Qemu-devel] [PATCH 06/31] pcspk: use QEMU_ALIGN_DOWN, Marc-André Lureau, 2017/06/22
- [Qemu-devel] [PATCH 07/31] dmg: use DIV_ROUND_UP, Marc-André Lureau, 2017/06/22
- [Qemu-devel] [PATCH 08/31] qcow2: use DIV_ROUND_UP, Marc-André Lureau, 2017/06/22