[PATCH 2/3] conf: enum cleanups in "src/conf/domain_conf.h"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In "src/conf/domain_conf.h" there are many enumerations (enum)
declarations to be converted as a typedef too. As mentioned before,
it's better to use a typedef for variable types, function types and
other usages. I think this file has most of those enum declarations
at "src/conf/". So, me and Eric Blake plan to keep the cleanups all
over the source code. This time, most of the files changed in this
commit are related to part of one file: "src/conf/domain_conf.h".

Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx>
---
 src/conf/domain_conf.c      |    4 +--
 src/conf/domain_conf.h      |   84 +++++++++++++++++++++----------------------
 src/qemu/qemu_command.c     |    4 +--
 src/qemu/qemu_domain.c      |    2 +-
 src/qemu/qemu_hotplug.c     |    2 +-
 src/security/security_dac.c |    4 +--
 6 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7ae63cc..75e6cfd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4099,7 +4099,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
  */
 static bool
 virDomainDriveAddressIsUsedByDisk(const virDomainDef *def,
-                                  enum virDomainDiskBus type,
+                                  virDomainDiskBus type,
                                   unsigned int controller,
                                   unsigned int unit)
 {
@@ -4128,7 +4128,7 @@ virDomainDriveAddressIsUsedByDisk(const virDomainDef *def,
  */
 static bool
 virDomainDriveAddressIsUsedByHostdev(const virDomainDef *def,
-                                     enum virDomainHostdevSubsysType type,
+                                     virDomainHostdevSubsysType type,
                                      unsigned int controller,
                                      unsigned int unit)
 {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bde303c..ced8c59 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -183,7 +183,7 @@ struct _virDomainDeviceDef {
 
 /* Different types of hypervisor */
 /* NB: Keep in sync with virDomainVirtTypeToString impl */
-enum virDomainVirtType {
+typedef enum {
     VIR_DOMAIN_VIRT_QEMU,
     VIR_DOMAIN_VIRT_KQEMU,
     VIR_DOMAIN_VIRT_KVM,
@@ -200,9 +200,9 @@ enum virDomainVirtType {
     VIR_DOMAIN_VIRT_BHYVE,
 
     VIR_DOMAIN_VIRT_LAST
-};
+} virDomainVirtType;
 
-enum virDomainDeviceAddressType {
+typedef enum {
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
@@ -216,15 +216,15 @@ enum virDomainDeviceAddressType {
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA,
 
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
-};
+} virDomainDeviceAddressType;
 
-enum virDomainPCIRombarMode {
+typedef enum {
     VIR_DOMAIN_PCI_ROMBAR_DEFAULT = 0,
     VIR_DOMAIN_PCI_ROMBAR_ON,
     VIR_DOMAIN_PCI_ROMBAR_OFF,
 
     VIR_DOMAIN_PCI_ROMBAR_LAST
-};
+} virDomainPCIRombarMode;
 
 typedef struct _virDomainDeviceDriveAddress virDomainDeviceDriveAddress;
 typedef virDomainDeviceDriveAddress *virDomainDeviceDriveAddressPtr;
@@ -277,12 +277,12 @@ struct _virDomainDeviceSpaprVioAddress {
     bool has_reg;
 };
 
-enum virDomainControllerMaster {
+typedef enum {
     VIR_DOMAIN_CONTROLLER_MASTER_NONE,
     VIR_DOMAIN_CONTROLLER_MASTER_USB,
 
     VIR_DOMAIN_CONTROLLER_MASTER_LAST
-};
+} virDomainControllerMaster;
 
 typedef struct _virDomainDeviceUSBMaster virDomainDeviceUSBMaster;
 typedef virDomainDeviceUSBMaster *virDomainDeviceUSBMasterPtr;
@@ -363,20 +363,20 @@ struct _virDomainLeaseDef {
 };
 
 
-enum virDomainHostdevMode {
+typedef enum {
     VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
     VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
 
     VIR_DOMAIN_HOSTDEV_MODE_LAST
-};
+} virDomainHostdevMode;
 
-enum virDomainHostdevSubsysType {
+typedef enum {
     VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
     VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
     VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
 
     VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
-};
+} virDomainHostdevSubsysType;
 
 /* the backend driver used for PCI hostdev devices */
 typedef enum {
@@ -419,13 +419,13 @@ struct _virDomainHostdevSubsys {
 };
 
 
-enum virDomainHostdevCapsType {
+typedef enum {
     VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
     VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
     VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
 
     VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
-};
+} virDomainHostdevCapsType;
 
 typedef struct _virDomainHostdevCaps virDomainHostdevCaps;
 typedef virDomainHostdevCaps *virDomainHostdevCapsPtr;
@@ -465,16 +465,16 @@ struct _virDomainHostdevDef {
 
 /* Types of disk frontend (guest view).  For backends (host view), see
  * virStorageType in util/virstoragefile.h */
-enum virDomainDiskDevice {
+typedef enum {
     VIR_DOMAIN_DISK_DEVICE_DISK,
     VIR_DOMAIN_DISK_DEVICE_CDROM,
     VIR_DOMAIN_DISK_DEVICE_FLOPPY,
     VIR_DOMAIN_DISK_DEVICE_LUN,
 
     VIR_DOMAIN_DISK_DEVICE_LAST
-};
+} virDomainDiskDevice;
 
-enum virDomainDiskBus {
+typedef enum {
     VIR_DOMAIN_DISK_BUS_IDE,
     VIR_DOMAIN_DISK_BUS_FDC,
     VIR_DOMAIN_DISK_BUS_SCSI,
@@ -486,9 +486,9 @@ enum virDomainDiskBus {
     VIR_DOMAIN_DISK_BUS_SD,
 
     VIR_DOMAIN_DISK_BUS_LAST
-};
+} virDomainDiskBus;
 
-enum virDomainDiskCache {
+typedef enum {
     VIR_DOMAIN_DISK_CACHE_DEFAULT,
     VIR_DOMAIN_DISK_CACHE_DISABLE,
     VIR_DOMAIN_DISK_CACHE_WRITETHRU,
@@ -497,9 +497,9 @@ enum virDomainDiskCache {
     VIR_DOMAIN_DISK_CACHE_UNSAFE,
 
     VIR_DOMAIN_DISK_CACHE_LAST
-};
+} virDomainDiskCache;
 
-enum virDomainDiskErrorPolicy {
+typedef enum {
     VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
     VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
     VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
@@ -507,82 +507,82 @@ enum virDomainDiskErrorPolicy {
     VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
 
     VIR_DOMAIN_DISK_ERROR_POLICY_LAST
-};
+} virDomainDiskErrorPolicy;
 
 
-enum virDomainDiskTray {
+typedef enum {
     VIR_DOMAIN_DISK_TRAY_CLOSED,
     VIR_DOMAIN_DISK_TRAY_OPEN,
 
     VIR_DOMAIN_DISK_TRAY_LAST
-};
+} virDomainDiskTray;
 
-enum virDomainDiskGeometryTrans {
+typedef enum {
     VIR_DOMAIN_DISK_TRANS_DEFAULT = 0,
     VIR_DOMAIN_DISK_TRANS_NONE,
     VIR_DOMAIN_DISK_TRANS_AUTO,
     VIR_DOMAIN_DISK_TRANS_LBA,
 
     VIR_DOMAIN_DISK_TRANS_LAST
-};
+} virDomainDiskGeometryTrans;
 
-enum virDomainDiskIo {
+typedef enum {
     VIR_DOMAIN_DISK_IO_DEFAULT,
     VIR_DOMAIN_DISK_IO_NATIVE,
     VIR_DOMAIN_DISK_IO_THREADS,
 
     VIR_DOMAIN_DISK_IO_LAST
-};
+} virDomainDiskIo;
 
-enum virDomainIoEventFd {
+typedef enum {
     VIR_DOMAIN_IO_EVENT_FD_DEFAULT = 0,
     VIR_DOMAIN_IO_EVENT_FD_ON,
     VIR_DOMAIN_IO_EVENT_FD_OFF,
 
     VIR_DOMAIN_IO_EVENT_FD_LAST
-};
+} virDomainIoEventFd;
 
-enum virDomainVirtioEventIdx {
+typedef enum {
     VIR_DOMAIN_VIRTIO_EVENT_IDX_DEFAULT = 0,
     VIR_DOMAIN_VIRTIO_EVENT_IDX_ON,
     VIR_DOMAIN_VIRTIO_EVENT_IDX_OFF,
 
     VIR_DOMAIN_VIRTIO_EVENT_IDX_LAST
-};
+} virDomainVirtioEventIdx;
 
-enum virDomainDiskCopyOnRead {
+typedef enum {
     VIR_DOMAIN_DISK_COPY_ON_READ_DEFAULT = 0,
     VIR_DOMAIN_DISK_COPY_ON_READ_ON,
     VIR_DOMAIN_DISK_COPY_ON_READ_OFF,
 
     VIR_DOMAIN_DISK_COPY_ON_READ_LAST
-};
+} virDomainDiskCopyOnRead;
 
-enum virDomainStartupPolicy {
+typedef enum {
     VIR_DOMAIN_STARTUP_POLICY_DEFAULT = 0,
     VIR_DOMAIN_STARTUP_POLICY_MANDATORY,
     VIR_DOMAIN_STARTUP_POLICY_REQUISITE,
     VIR_DOMAIN_STARTUP_POLICY_OPTIONAL,
 
     VIR_DOMAIN_STARTUP_POLICY_LAST
-};
+} virDomainStartupPolicy;
 
 
-enum virDomainDeviceSGIO {
+typedef enum {
     VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
     VIR_DOMAIN_DEVICE_SGIO_FILTERED,
     VIR_DOMAIN_DEVICE_SGIO_UNFILTERED,
 
     VIR_DOMAIN_DEVICE_SGIO_LAST
-};
+} virDomainDeviceSGIO;
 
-enum virDomainDiskDiscard {
+typedef enum {
     VIR_DOMAIN_DISK_DISCARD_DEFAULT = 0,
     VIR_DOMAIN_DISK_DISCARD_UNMAP,
     VIR_DOMAIN_DISK_DISCARD_IGNORE,
 
     VIR_DOMAIN_DISK_DISCARD_LAST
-};
+} virDomainDiskDiscard;
 
 typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo;
 struct _virDomainBlockIoTuneInfo {
@@ -866,8 +866,8 @@ struct _virDomainNetDef {
         struct {
             enum virDomainNetBackendType name; /* which driver backend to use */
             enum virDomainNetVirtioTxModeType txmode;
-            enum virDomainIoEventFd ioeventfd;
-            enum virDomainVirtioEventIdx event_idx;
+            virDomainIoEventFd ioeventfd;
+            virDomainVirtioEventIdx event_idx;
             unsigned int queues; /* Multiqueue virtio-net */
         } virtio;
     } driver;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0a7b2ff..0216a2c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1143,7 +1143,7 @@ int qemuDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
 
 static void
 qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def,
-                                     enum virDomainDeviceAddressType type)
+                                     virDomainDeviceAddressType type)
 {
     /*
        declare address-less virtio devices to be of address type 'type'
@@ -2595,7 +2595,7 @@ qemuBuildRomStr(virBufferPtr buf,
 
 static int
 qemuBuildIoEventFdStr(virBufferPtr buf,
-                      enum virDomainIoEventFd use,
+                      virDomainIoEventFd use,
                       virQEMUCapsPtr qemuCaps)
 {
     if (use && virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_IOEVENTFD))
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 78cfdc6..8f14259 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2221,7 +2221,7 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
 
     virUUIDFormat(vm->def->uuid, uuid);
 
-    switch ((enum virDomainStartupPolicy) startupPolicy) {
+    switch ((virDomainStartupPolicy) startupPolicy) {
         case VIR_DOMAIN_STARTUP_POLICY_OPTIONAL:
             break;
 
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 76e289b..982db76 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2598,7 +2598,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
 
     virDomainAuditHostdev(vm, hostdev, "detach", true);
 
-    switch ((enum virDomainHostdevSubsysType) hostdev->source.subsys.type) {
+    switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) {
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
         qemuDomainRemovePCIHostDevice(driver, vm, hostdev);
         break;
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 00f47cb..73bd83a 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -488,7 +488,7 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
     if (cbdata.secdef && cbdata.secdef->norelabel)
         return 0;
 
-    switch ((enum virDomainHostdevSubsysType) dev->source.subsys.type) {
+    switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
         virUSBDevicePtr usb;
 
@@ -615,7 +615,7 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
     if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
         return 0;
 
-    switch ((enum virDomainHostdevSubsysType) dev->source.subsys.type) {
+    switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
         virUSBDevicePtr usb;
 
-- 
1.7.10.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]