Skip to contentSkip to conversation

checkpatch: don't error out on },{ lines

PATCH In review Alexander Graf 2 participants 2 messages Jun 30, 2011 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: don't error out on },{ lines

When having code like this:

    static PCIDeviceInfo piix_ide_info[] = {
        {
            .qdev.name    = "piix3-ide",
            .qdev.size    = sizeof(PCIIDEState),
            .qdev.no_user = 1,
            .no_hotplug   = 1,
            .init         = pci_piix_ide_initfn,
            .vendor_id    = PCI_VENDOR_ID_INTEL,
            .device_id    = PCI_DEVICE_ID_INTEL_82371SB_1,
            .class_id     = PCI_CLASS_STORAGE_IDE,
        },{
            .qdev.name    = "piix4-ide",
            .qdev.size    = sizeof(PCIIDEState),
            .qdev.no_user = 1,
            .no_hotplug   = 1,
            .init         = pci_piix_ide_initfn,
            .vendor_id    = PCI_VENDOR_ID_INTEL,
            .device_id    = PCI_DEVICE_ID_INTEL_82371AB,
            .class_id     = PCI_CLASS_STORAGE_IDE,
        },{
            /* end of list */
        }
    };

checkpatch currently errors out, claiming that spaces need to follow commas. However, this particular style of defining structs is pretty common in qemu code and very readable. So let's declare it as supported for the above case.

---
 scripts/checkpatch.pl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
scripts/checkpatch.pl +3 -1
index 075b614..70a2111 100755
@@ -2068,8 +2068,10 @@ sub process {
 					}
 
 				# , must have a space on the right.
+                                # not required when having a single },{ on one line
 				} elsif ($op eq ',') {
-					if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) {
+					if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/ &&
+                                            ($elements[$n] . $elements[$n + 2]) !~ " *}{") {
 						ERROR("space required after that '$op' $at\n" . $hereptr);
 					}
 
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 31 lines · Alexander Graf

When having code like this:

   static PCIDeviceInfo piix_ide_info[] = {
       {
           .qdev.name    = "piix3-ide", .qdev.size    = sizeof(PCIIDEState), .qdev.no_user = 1,
           .no_hotplug   = 1,
           .init         = pci_piix_ide_initfn, .vendor_id    = PCI_VENDOR_ID_INTEL, .device_id    = PCI_DEVICE_ID_INTEL_82371SB_1, .class_id     = PCI_CLASS_STORAGE_IDE, },{
           .qdev.name    = "piix4-ide", .qdev.size    = sizeof(PCIIDEState), .qdev.no_user = 1,
           .no_hotplug   = 1,
           .init         = pci_piix_ide_initfn, .vendor_id    = PCI_VENDOR_ID_INTEL, .device_id    = PCI_DEVICE_ID_INTEL_82371AB, .class_id     = PCI_CLASS_STORAGE_IDE, },{
           /* end of list */
       }
   };

checkpatch currently errors out, claiming that spaces need to follow commas. However, this particular style of defining structs is pretty common in qemu code and very readable. So let's declare it as supported for the above case.

Quoted 5 lines

---
 scripts/checkpatch.pl |    4 +++-

 1 files changed, 3 insertions(+), 1 deletions(-)

Good idea. I was going to go and change qemu-config.c but updating checkpatch.pl probably makes more sense.

Stefan