diff mbox series

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

Message ID 20240216110313.17039-2-philmd@linaro.org
State New
Headers show
Series hw: More QDev cleanups | expand

Commit Message

Philippe Mathieu-Daudé Feb. 16, 2024, 11:02 a.m. UTC
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(-)

Comments

Zhao Liu Feb. 22, 2024, 9:12 a.m. UTC | #1
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);
}
Philippe Mathieu-Daudé Feb. 22, 2024, 10:10 a.m. UTC | #2
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!
diff mbox series

Patch

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);
         }