[Top][All Lists]

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

Re: [Qemu-devel] [PATCH 1.1] virtio: Fix compiler warning for non Linux

From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 1.1] virtio: Fix compiler warning for non Linux hosts
Date: Mon, 28 May 2012 13:39:58 +0100

On Wed, May 23, 2012 at 5:03 PM, Stefan Weil <address@hidden> wrote:
> Am 23.05.2012 17:32, schrieb Kevin Wolf:
>> Am 23.05.2012 17:29, schrieb Stefan Weil:
>>> Am 23.05.2012 10:09, schrieb Stefan Hajnoczi:
>>>> On Tue, May 22, 2012 at 10:23 PM, Stefan Weil<address@hidden>   wrote:
>>>>> The local variables ret, i are only used if __linux__ is defined.
>>>>> Signed-off-by: Stefan Weil<address@hidden>
>>>>> ---
>>>>>   hw/virtio-blk.c |    4 +++-
>>>>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>>> The #ifdef __linux__ further down in the function declares the local
>>>> hdr variable.  We could move ret and i down into the #ifdef instead of
>>>> adding a new one.
>>> I noticed that, but declaring variables anywhere is C++, not C code.
>> It's called C99.
>> Kevin
> Maybe, but I already had patches rejected because of that style.
> Did this policy change? I'd appreciate that!

Agreed, people have been asked to declare variables at the beginning
of the scope.  I don't understand why, C99 allows them to be declared
anywhere and it usually makes the code more readable IMO (you don't
have to jump to the definition to check a variable's type).

What's the problem with C99-style variable declarations anywhere in a function?


reply via email to

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