[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/5] coccinelle: use DIV_ROUND_UP
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 2/5] coccinelle: use DIV_ROUND_UP |
Date: |
Wed, 7 Jun 2017 10:13:00 +0100 |
On 7 June 2017 at 08:46, Marc-André Lureau <address@hidden> wrote:
> The coccinelle/round.cocci script doesn't catch hard coded values.
>
> I used the following script over qemu code base:
>
> (
> - ((e1) + 3) / (4)
> + DIV_ROUND_UP(e1,4)
> |
> - ((e1) + (3)) / (4)
> + DIV_ROUND_UP(e1,4)
Why do we need both of these? Is it just "coccinelle is weird" ? :-)
> |
> - ((e1) + 7) / (8)
> + DIV_ROUND_UP(e1,8)
> |
> - ((e1) + (7)) / (8)
> + DIV_ROUND_UP(e1,8)
> |
> - ((e1) + 15) / (16)
> + DIV_ROUND_UP(e1,16)
> |
> - ((e1) + (15)) / (16)
> + DIV_ROUND_UP(e1,16)
> |
> - ((e1) + 31) / (32)
> + DIV_ROUND_UP(e1,32)
> |
> - ((e1) + (31)) / (32)
> + DIV_ROUND_UP(e1,32)
> )
> - next_op = op_pointer + ((oplen + 7) / 8);
> + next_op = op_pointer + (DIV_ROUND_UP(oplen, 8));
I think there's a coccinelle trick for making it drop
now-unnecessary brackets in substitutions like this, but I forget
what it is. Maybe it's as simple as having substitutions for
> - (((e1) + 7) / (8))
> + DIV_ROUND_UP(e1,8)
as well?
thanks
-- PMM
- [Qemu-devel] [PATCH 0/5] Code cleanups with Coccinelle, Marc-André Lureau, 2017/06/07
- [Qemu-devel] [PATCH 1/5] coccinelle: replace code with ROUND_UP macro, Marc-André Lureau, 2017/06/07
- [Qemu-devel] [PATCH 2/5] coccinelle: use DIV_ROUND_UP, Marc-André Lureau, 2017/06/07
- [Qemu-devel] [PATCH 3/5] arch: introduce ELF_NOTE_SIZE macro, Marc-André Lureau, 2017/06/07
- [Qemu-devel] [PATCH 4/5] Replace g_malloc()+memcpy() with g_memdup(), Marc-André Lureau, 2017/06/07
- [Qemu-devel] [PATCH 5/5] coccinelle: prefer glib g_new/g_renew macros, Marc-André Lureau, 2017/06/07