qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Qemu-arm] [PATCH 3/3] hw/misc/exynos4210_pmu: Reorder


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [Qemu-arm] [PATCH 3/3] hw/misc/exynos4210_pmu: Reorder local variables for readability
Date: Mon, 6 Mar 2017 10:34:29 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1

On 03/06/2017 10:16 AM, Peter Maydell wrote:
On 6 March 2017 at 13:03, Paolo Bonzini <address@hidden> wrote:
On 06/03/2017 10:46, Peter Maydell wrote:
On 6 March 2017 at 04:06, Philippe Mathieu-Daudé <address@hidden> wrote:
your change seems OK but while you are here, 'unsigned' is considered
harmful since more than a decade.

Considered harmful by who, and why?

sorry to cry wolf :)

It is true that unsigned has all the disadvantages of "int" (it may be
smaller than the size of the object" and all the disadvantages of
"size_t" (it doesn't optimize as well because the compiler cannot
exploit undefined behavior).

I wouldn't call it harmful, but it feels like the worst of both worlds.

size_t is a pretty silly choice for a variable that's looping
through the number of registers in the device, which is a value
that would fit in 16 bits, let alone 32. I would probably have
written this with 'int', but use of 'unsigned' doesn't come
very high up on my list of things to complain about.

silly would be "typeof(PMU_NUM_OF_REGISTERS) i;" :p

I got your point about the complain priority list.

(since we use -fwrapv the compiler can't exploit undefined
behaviour for signed loop indexes either.)

regards,

Phil.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]