[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled |
Date: |
Fri, 15 Nov 2019 17:13:55 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 15/11/19 16:54, Thomas Huth wrote:
> On 15/11/2019 16.54, Peter Maydell wrote:
>> On Fri, 15 Nov 2019 at 15:10, Thomas Huth <address@hidden> wrote:
>>>
>>> When CONFIG_IDE_ISA is disabled, compilation currently fails:
>>>
>>> hw/i386/pc_piix.c: In function ‘pc_init1’:
>>> hw/i386/pc_piix.c:81:9: error: unused variable ‘i’
>>> [-Werror=unused-variable]
>>>
>>> Move the variable declaration to the right code block to avoid
>>> this problem.
>>>
>>> Fixes: 4501d317b50e ("hw/i386/pc: Extract pc_i8259_create()")
>>> Signed-off-by: Thomas Huth <address@hidden>
>>> ---
>>> hw/i386/pc_piix.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>>> index 2aefa3b8df..d187db761c 100644
>>> --- a/hw/i386/pc_piix.c
>>> +++ b/hw/i386/pc_piix.c
>>> @@ -78,7 +78,6 @@ static void pc_init1(MachineState *machine,
>>> X86MachineState *x86ms = X86_MACHINE(machine);
>>> MemoryRegion *system_memory = get_system_memory();
>>> MemoryRegion *system_io = get_system_io();
>>> - int i;
>>> PCIBus *pci_bus;
>>> ISABus *isa_bus;
>>> PCII440FXState *i440fx_state;
>>> @@ -253,7 +252,7 @@ static void pc_init1(MachineState *machine,
>>> }
>>> #ifdef CONFIG_IDE_ISA
>>> else {
>>> - for(i = 0; i < MAX_IDE_BUS; i++) {
>>> + for (int i = 0; i < MAX_IDE_BUS; i++) {
>>> ISADevice *dev;
>>> char busname[] = "ide.0";
>>> dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
>>
>> Don't put variable declarations inside 'for' statements,
>> please. They should go at the start of a {} block.
>
> Why? We're using -std=gnu99 now, so this should not be an issue anymore.
For now I can squash the following while we discuss coding standards. :)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index fa62244f4d..0130b8fb4e 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -244,7 +244,8 @@ static void pc_init1(MachineState *machine,
}
#ifdef CONFIG_IDE_ISA
else {
- for (int i = 0; i < MAX_IDE_BUS; i++) {
+ int i;
+ for (i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
char busname[] = "ide.0";
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
Paolo
- [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Thomas Huth, 2019/11/15
- Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Michael S. Tsirkin, 2019/11/15
- Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Peter Maydell, 2019/11/15
- Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Peter Maydell, 2019/11/15
- Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Thomas Huth, 2019/11/15
- Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Philippe Mathieu-Daudé, 2019/11/15
- Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Markus Armbruster, 2019/11/18
- Re: [PATCH for-4.2] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Thomas Huth, 2019/11/18