On 15/11/2019 17.15, Peter Maydell wrote: > On Fri, 15 Nov 2019 at 16:08, Thomas Huth <th...@redhat.com> wrote: >> >> On 15/11/2019 16.54, Peter Maydell wrote: >>> On Fri, 15 Nov 2019 at 15:10, Thomas Huth <th...@redhat.com> wrote: >>>> --- 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. > > Consistency with the rest of the code base, which mostly > avoids this particular trick.
We've also got a few spots that use it... (run e.g.: grep -r 'for (int ' hw/* ) > See the 'Declarations' section of CODING_STYLE.rst. OK, that's a point. But since this gnu99 is a rather new option that we just introduced less than a year ago, we should maybe think of whether we want to allow this for for-loops now, too (since IMHO it's quite a nice feature in gnu99). Thomas