[Top][All Lists]

[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: Peter Maydell
Subject: Re: [Qemu-devel] [Qemu-arm] [PATCH 3/3] hw/misc/exynos4210_pmu: Reorder local variables for readability
Date: Mon, 6 Mar 2017 13:16:15 +0000

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?
> 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.

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

-- PMM

reply via email to

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