[PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style

Philippe Mathieu-Daudé posted 21 patches 8 months, 2 weeks ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Jan Kiszka <jan.kiszka@web.de>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Alistair Francis <alistair@alistair23.me>, Richard Henderson <richard.henderson@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Pavel Pisa <pisa@cmp.felk.cvut.cz>, Vikram Garhwal <fnu.vikram@xilinx.com>, Francisco Iglesias <francisco.iglesias@amd.com>, Jason Wang <jasowang@redhat.com>, Chris Wulff <crwulff@gmail.com>, Marek Vasut <marex@denx.de>, "Hervé Poussineau" <hpoussin@reactos.org>, "Cédric Le Goater" <clg@kaod.org>, Nicholas Piggin <npiggin@gmail.com>, "Frédéric Barrat" <fbarrat@linux.ibm.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Gerd Hoffmann <kraxel@redhat.com>, Samuel Thibault <samuel.thibault@ens-lyon.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Max Filippov <jcmvbkbc@gmail.com>
[PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style
Posted by Philippe Mathieu-Daudé 8 months, 2 weeks ago
QEMU's coding style generally forbids C99 mixed declarations.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/i386/pc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 196827531a..3c00a87317 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1227,6 +1227,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
      */
     if (pcms->hpet_enabled) {
         qemu_irq rtc_irq;
+        uint8_t compat;
 
         hpet = qdev_try_new(TYPE_HPET);
         if (!hpet) {
@@ -1238,8 +1239,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
          * use IRQ16~23, IRQ8 and IRQ2.  If the user has already set
          * the property, use whatever mask they specified.
          */
-        uint8_t compat = object_property_get_uint(OBJECT(hpet),
-                HPET_INTCAP, NULL);
+        compat = object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL);
         if (!compat) {
             qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
         }
-- 
2.41.0


Re: [PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style
Posted by Zhao Liu 8 months, 1 week ago
Hi Philippe,

On Fri, Feb 16, 2024 at 12:02:52PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Fri, 16 Feb 2024 12:02:52 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style
> X-Mailer: git-send-email 2.41.0
> 
> QEMU's coding style generally forbids C99 mixed declarations.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/i386/pc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 196827531a..3c00a87317 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1227,6 +1227,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
>       */
>      if (pcms->hpet_enabled) {
>          qemu_irq rtc_irq;
> +        uint8_t compat;
>  
>          hpet = qdev_try_new(TYPE_HPET);
>          if (!hpet) {
> @@ -1238,8 +1239,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
>           * use IRQ16~23, IRQ8 and IRQ2.  If the user has already set
>           * the property, use whatever mask they specified.
>           */
> -        uint8_t compat = object_property_get_uint(OBJECT(hpet),
> -                HPET_INTCAP, NULL);
> +        compat = object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL);
>          if (!compat) {
>              qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
>          }

"compat" is only used here to check. So, what about getting rid of this
variable?

if (!object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL)) {
    qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
}
Re: [PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style
Posted by Philippe Mathieu-Daudé 8 months, 1 week ago
On 22/2/24 10:12, Zhao Liu wrote:
> Hi Philippe,
> 
> On Fri, Feb 16, 2024 at 12:02:52PM +0100, Philippe Mathieu-Daudé wrote:
>> Date: Fri, 16 Feb 2024 12:02:52 +0100
>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Subject: [PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style
>> X-Mailer: git-send-email 2.41.0
>>
>> QEMU's coding style generally forbids C99 mixed declarations.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   hw/i386/pc.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
>> index 196827531a..3c00a87317 100644
>> --- a/hw/i386/pc.c
>> +++ b/hw/i386/pc.c
>> @@ -1227,6 +1227,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
>>        */
>>       if (pcms->hpet_enabled) {
>>           qemu_irq rtc_irq;
>> +        uint8_t compat;
>>   
>>           hpet = qdev_try_new(TYPE_HPET);
>>           if (!hpet) {
>> @@ -1238,8 +1239,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
>>            * use IRQ16~23, IRQ8 and IRQ2.  If the user has already set
>>            * the property, use whatever mask they specified.
>>            */
>> -        uint8_t compat = object_property_get_uint(OBJECT(hpet),
>> -                HPET_INTCAP, NULL);
>> +        compat = object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL);
>>           if (!compat) {
>>               qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
>>           }
> 
> "compat" is only used here to check. So, what about getting rid of this
> variable?
> 
> if (!object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL)) {
>      qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
> }

Ah yeah, I didn't noticed, thanks!