]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: don't use "class" as name
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Tue, 12 Mar 2019 08:08:00 +0000 (11:08 +0300)
committerNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Mon, 18 Mar 2019 08:14:37 +0000 (11:14 +0300)
Vim treats *.h files as cpp ones with respect to syntax highlighting.
Thus "class" in _virNodeDevCapPCIDev highlighted mistakenly.
This can be fixed by filetype detection code tunables but it
is more convinient to skip this tuning by every project member.

Let's just use "klass" as field name instead of _class or class
and add syntax rule.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
cfg.mk
src/conf/node_device_conf.c
src/conf/node_device_conf.h
src/node_device/node_device_udev.c
tests/virpcimock.c

diff --git a/cfg.mk b/cfg.mk
index f99b8ae63102f396bae03be75efd8ea2d2118f16..a62d4db13bc9c8856f58f5a882668c3a98c4522c 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -1075,6 +1075,15 @@ sc_require_attribute_cleanup_initialization:
        halt='variable declared with a cleanup macro must be initialized' \
          $(_sc_search_regexp)
 
+# "class" in headers is not good because by default Vim treats it as a keyword
+# Let's prohibit it in source files as well.
+sc_prohibit_class:
+       @prohibit=' +_?class *;' \
+       in_vc_files='\.[chx]$$' \
+       halt='use klass instead of class or _class' \
+         $(_sc_search_regexp)
+
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null
 
index 1b1f57d0650fa396b3d45c3ba40c7192670d7d43..5de51d1f6b4b64edd03216f526892343f73354e7 100644 (file)
@@ -346,7 +346,7 @@ virNodeDeviceCapUSBInterfaceDefFormat(virBufferPtr buf,
     virBufferAsprintf(buf, "<number>%d</number>\n",
                       data->usb_if.number);
     virBufferAsprintf(buf, "<class>%d</class>\n",
-                      data->usb_if._class);
+                      data->usb_if.klass);
     virBufferAsprintf(buf, "<subclass>%d</subclass>\n",
                       data->usb_if.subclass);
     virBufferAsprintf(buf, "<protocol>%d</protocol>\n",
@@ -1216,7 +1216,7 @@ virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPtr ctxt,
         goto out;
 
     if (virNodeDevCapsDefParseULong("number(./class[1])", ctxt,
-                                    &usb_if->_class, def,
+                                    &usb_if->klass, def,
                                     _("no USB interface class supplied for '%s'"),
                                     _("invalid USB interface class supplied for '%s'")) < 0)
         goto out;
index ce789e9ee96da975bb1d63a9826612dabb8603d2..b13bc13b87fbbb0771a2815d9b45e1c374d80f92 100644 (file)
@@ -153,7 +153,7 @@ struct _virNodeDevCapPCIDev {
     unsigned int function;
     unsigned int product;
     unsigned int vendor;
-    unsigned int class;
+    unsigned int klass;
     char *product_name;
     char *vendor_name;
     virPCIDeviceAddressPtr physical_function;
@@ -186,7 +186,7 @@ typedef struct _virNodeDevCapUSBIf virNodeDevCapUSBIf;
 typedef virNodeDevCapUSBIf *virNodeDevCapUSBIfPtr;
 struct _virNodeDevCapUSBIf {
     unsigned int number;
-    unsigned int _class;                /* "class" is reserved in C */
+    unsigned int klass;
     unsigned int subclass;
     unsigned int protocol;
     char *description;
index 32e762009f1ca7886578ac9f7581c528a5436783..f0e61e4236b5ee210d0f1ca4b265ac84fc7dc4d3 100644 (file)
@@ -402,7 +402,7 @@ udevProcessPCI(struct udev_device *device,
     privileged = driver->privileged;
     nodeDeviceUnlock();
 
-    if (udevGetUintProperty(device, "PCI_CLASS", &pci_dev->class, 16) < 0)
+    if (udevGetUintProperty(device, "PCI_CLASS", &pci_dev->klass, 16) < 0)
         goto cleanup;
 
     if ((p = strrchr(def->sysfs_path, '/')) == NULL ||
@@ -582,7 +582,7 @@ udevProcessUSBInterface(struct udev_device *device,
         return -1;
 
     if (udevGetUintSysfsAttr(device, "bInterfaceClass",
-                             &usb_if->_class, 16) < 0)
+                             &usb_if->klass, 16) < 0)
         return -1;
 
     if (udevGetUintSysfsAttr(device, "bInterfaceSubClass",
index acde380c5d7b0c6ed790bb84da9bbf701c28ba1d..ce8176cbec00f4b3b71569c5e88cb1a40487a8f6 100644 (file)
@@ -122,7 +122,7 @@ struct pciDevice {
     char *id;
     int vendor;
     int device;
-    int class;
+    int klass;
     int iommuGroup;
     struct pciDriver *driver;   /* Driver attached. NULL if attached to no driver */
 };
@@ -404,7 +404,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
         ABORT("@tmp overflow");
     make_file(devpath, "device", tmp, -1);
 
-    if (snprintf(tmp, sizeof(tmp),  "0x%.4x", dev->class) < 0)
+    if (snprintf(tmp, sizeof(tmp),  "0x%.4x", dev->klass) < 0)
         ABORT("@tmp overflow");
     make_file(devpath, "class", tmp, -1);
 
@@ -858,10 +858,10 @@ init_env(void)
     MAKE_PCI_DEVICE("0000:00:01.0", 0x8086, 0x0044);
     MAKE_PCI_DEVICE("0000:00:02.0", 0x8086, 0x0046);
     MAKE_PCI_DEVICE("0000:00:03.0", 0x8086, 0x0048);
-    MAKE_PCI_DEVICE("0001:00:00.0", 0x1014, 0x03b9, .class = 0x060400);
+    MAKE_PCI_DEVICE("0001:00:00.0", 0x1014, 0x03b9, .klass = 0x060400);
     MAKE_PCI_DEVICE("0001:01:00.0", 0x8086, 0x105e, .iommuGroup = 0);
     MAKE_PCI_DEVICE("0001:01:00.1", 0x8086, 0x105e, .iommuGroup = 0);
-    MAKE_PCI_DEVICE("0005:80:00.0", 0x10b5, 0x8112, .class = 0x060400);
+    MAKE_PCI_DEVICE("0005:80:00.0", 0x10b5, 0x8112, .klass = 0x060400);
     MAKE_PCI_DEVICE("0005:90:01.0", 0x1033, 0x0035, .iommuGroup = 1);
     MAKE_PCI_DEVICE("0005:90:01.1", 0x1033, 0x0035, .iommuGroup = 1);
     MAKE_PCI_DEVICE("0005:90:01.2", 0x1033, 0x00e0, .iommuGroup = 1);