[libvirt] [PATCH 1/5] conf: changing all the "enum" structures into typedef's in "src/conf/" directory.

In "src/conf/" there are many enumeration (enum) structures like "src/util" directory. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future. Most of the files changed in this commit included CPU (cpu_conf) enum structures. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/conf/cpu_conf.c | 2 +- src/conf/cpu_conf.h | 22 +++++++++++----------- src/conf/device_conf.h | 4 ++-- src/cpu/cpu_powerpc.c | 2 +- src/cpu/cpu_x86.c | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index a8b1b03..ebdaa19 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -176,7 +176,7 @@ virCPUDefCopy(const virCPUDef *cpu) virCPUDefPtr virCPUDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, - enum virCPUType mode) + virCPUType mode) { virCPUDefPtr def; xmlNodePtr *nodes = NULL; diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index dbe7103..8c932ce 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -32,46 +32,46 @@ # define VIR_CPU_VENDOR_ID_LENGTH 12 -enum virCPUType { +typedef enum { VIR_CPU_TYPE_HOST, VIR_CPU_TYPE_GUEST, VIR_CPU_TYPE_AUTO, VIR_CPU_TYPE_LAST -}; +} virCPUType; VIR_ENUM_DECL(virCPU) -enum virCPUMode { +typedef enum { VIR_CPU_MODE_CUSTOM, VIR_CPU_MODE_HOST_MODEL, VIR_CPU_MODE_HOST_PASSTHROUGH, VIR_CPU_MODE_LAST -}; +} virCPUMode; VIR_ENUM_DECL(virCPUMode) -enum virCPUMatch { +typedef enum { VIR_CPU_MATCH_MINIMUM, VIR_CPU_MATCH_EXACT, VIR_CPU_MATCH_STRICT, VIR_CPU_MATCH_LAST -}; +} virCPUMatch; VIR_ENUM_DECL(virCPUMatch) -enum virCPUFallback { +typedef enum { VIR_CPU_FALLBACK_ALLOW, VIR_CPU_FALLBACK_FORBID, VIR_CPU_FALLBACK_LAST -}; +} virCPUFallback; VIR_ENUM_DECL(virCPUFallback) -enum virCPUFeaturePolicy { +typedef enum { VIR_CPU_FEATURE_FORCE, VIR_CPU_FEATURE_REQUIRE, VIR_CPU_FEATURE_OPTIONAL, @@ -79,7 +79,7 @@ enum virCPUFeaturePolicy { VIR_CPU_FEATURE_FORBID, VIR_CPU_FEATURE_LAST -}; +} virCPUFeaturePolicy; VIR_ENUM_DECL(virCPUFeaturePolicy) @@ -140,7 +140,7 @@ virCPUDefCopy(const virCPUDef *cpu); virCPUDefPtr virCPUDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, - enum virCPUType mode); + virCPUType mode); bool virCPUDefIsEqual(virCPUDefPtr src, diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 7986ca6..d66afd2 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -32,13 +32,13 @@ # include "virthread.h" # include "virbuffer.h" -enum virDeviceAddressPCIMulti { +typedef enum { VIR_DEVICE_ADDRESS_PCI_MULTI_DEFAULT = 0, VIR_DEVICE_ADDRESS_PCI_MULTI_ON, VIR_DEVICE_ADDRESS_PCI_MULTI_OFF, VIR_DEVICE_ADDRESS_PCI_MULTI_LAST -}; +} virDeviceAddressPCIMulti; typedef struct _virDevicePCIAddress virDevicePCIAddress; typedef virDevicePCIAddress *virDevicePCIAddressPtr; diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c index 3b868bb..372272f 100644 --- a/src/cpu/cpu_powerpc.c +++ b/src/cpu/cpu_powerpc.c @@ -534,7 +534,7 @@ static int ppcUpdate(virCPUDefPtr guest, const virCPUDef *host) { - switch ((enum virCPUMode) guest->mode) { + switch ((virCPUMode) guest->mode) { case VIR_CPU_MODE_HOST_MODEL: case VIR_CPU_MODE_HOST_PASSTHROUGH: guest->match = VIR_CPU_MATCH_EXACT; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 7328582..06fbfba 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1615,7 +1615,7 @@ x86DecodeCPUData(virCPUDefPtr cpu, static virCPUx86Data * x86EncodePolicy(const virCPUDef *cpu, const struct x86_map *map, - enum virCPUFeaturePolicy policy) + virCPUFeaturePolicy policy) { struct x86_model *model; virCPUx86Data *data = NULL; @@ -2045,7 +2045,7 @@ static int x86Update(virCPUDefPtr guest, const virCPUDef *host) { - switch ((enum virCPUMode) guest->mode) { + switch ((virCPUMode) guest->mode) { case VIR_CPU_MODE_CUSTOM: return x86UpdateCustom(guest, host); -- 1.7.10.4

In "src/conf/" there are many enumeration (enum) structures like "src/util" directory. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future. Most of the files changed in this commit included Network (network_conf.* and interface_conf.*) enum structures. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/conf/interface_conf.c | 2 +- src/conf/interface_conf.h | 26 +++++++++++++------------- src/conf/network_conf.c | 2 +- src/conf/network_conf.h | 14 +++++++------- src/network/bridge_driver.c | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index b1b56c8..1f67446 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -1030,7 +1030,7 @@ virInterfaceProtocolDefFormat(virBufferPtr buf, const virInterfaceDef *def) static int virInterfaceStartmodeDefFormat(virBufferPtr buf, - enum virInterfaceStartMode startmode) + virInterfaceStartMode startmode) { const char *mode; switch (startmode) { diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h index 2c759bc..b3c92b2 100644 --- a/src/conf/interface_conf.h +++ b/src/conf/interface_conf.h @@ -34,27 +34,27 @@ /* There is currently 3 types of interfaces */ -enum virInterfaceType { +typedef enum { VIR_INTERFACE_TYPE_ETHERNET, /* simple ethernet */ VIR_INTERFACE_TYPE_BRIDGE, /* bridge interface */ VIR_INTERFACE_TYPE_BOND, /* bonding interface */ VIR_INTERFACE_TYPE_VLAN, /* vlan description */ VIR_INTERFACE_TYPE_LAST, -}; +} virInterfaceType; VIR_ENUM_DECL(virInterface) /* types of start mode */ -enum virInterfaceStartMode { +typedef enum { VIR_INTERFACE_START_UNSPECIFIED = 0, /* not given in config */ VIR_INTERFACE_START_NONE, /* specified as not defined */ VIR_INTERFACE_START_ONBOOT, /* startup at boot */ VIR_INTERFACE_START_HOTPLUG, /* on hotplug */ -}; +} virInterfaceStartMode; -enum virInterfaceBondMode { +typedef enum { VIR_INTERFACE_BOND_NONE = 0, VIR_INTERFACE_BOND_BALRR, /* balance-rr */ VIR_INTERFACE_BOND_ABACKUP, /* active backup */ @@ -63,26 +63,26 @@ enum virInterfaceBondMode { VIR_INTERFACE_BOND_8023AD, /* 802.3ad */ VIR_INTERFACE_BOND_BALTLB, /* balance-tlb */ VIR_INTERFACE_BOND_BALALB, /* balance-alb */ -}; +} virInterfaceBondMode; -enum virInterfaceBondMonit { +typedef enum { VIR_INTERFACE_BOND_MONIT_NONE = 0, VIR_INTERFACE_BOND_MONIT_MII, /* mii based monitoring */ VIR_INTERFACE_BOND_MONIT_ARP, /* arp based monitoring */ -}; +} virInterfaceBondMonit; -enum virInterfaceBondMiiCarrier { +typedef enum { VIR_INTERFACE_BOND_MII_NONE = 0, VIR_INTERFACE_BOND_MII_IOCTL, /* mii/ethtool ioctl */ VIR_INTERFACE_BOND_MII_NETIF, /* netif_carrier_ok */ -}; +} virInterfaceBondMiiCarrier; -enum virInterfaceBondArpValid { +typedef enum { VIR_INTERFACE_BOND_ARP_NONE = 0, VIR_INTERFACE_BOND_ARP_ACTIVE, /* validate active */ VIR_INTERFACE_BOND_ARP_BACKUP, /* validate backup */ VIR_INTERFACE_BOND_ARP_ALL, /* validate all */ -}; +} virInterfaceBondArpValid; struct _virInterfaceDef; /* forward declaration required for bridge/bond */ @@ -147,7 +147,7 @@ struct _virInterfaceDef { unsigned int mtu; /* maximum transmit size in byte */ char *mac; /* MAC address */ - enum virInterfaceStartMode startmode; /* how it is started */ + virInterfaceStartMode startmode; /* how it is started */ union { virInterfaceBridgeDef bridge; diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 41465c2..30b9916 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -77,7 +77,7 @@ VIR_ENUM_IMPL(virNetworkTaint, VIR_NETWORK_TAINT_LAST, bool virNetworkObjTaint(virNetworkObjPtr obj, - enum virNetworkTaintFlags taint) + virNetworkTaintFlags taint) { unsigned int flag = (1 << taint); diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index 90da16f..c4e9d92 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -40,7 +40,7 @@ # include "device_conf.h" # include "virbitmap.h" -enum virNetworkForwardType { +typedef enum { VIR_NETWORK_FORWARD_NONE = 0, VIR_NETWORK_FORWARD_NAT, VIR_NETWORK_FORWARD_ROUTE, @@ -51,16 +51,16 @@ enum virNetworkForwardType { VIR_NETWORK_FORWARD_HOSTDEV, VIR_NETWORK_FORWARD_LAST, -}; +} virNetworkForwardType; -enum virNetworkForwardHostdevDeviceType { +typedef enum { VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NONE = 0, VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI, VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV, /* USB Device to be added here when supported */ VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_LAST, -}; +} virNetworkForwardHostdevDeviceType; /* The backend driver used for devices from the pool. Currently used * only for PCI devices (vfio vs. kvm), but could be used for other @@ -298,7 +298,7 @@ struct _virNetworkObjList { virNetworkObjPtr *objs; }; -enum virNetworkTaintFlags { +typedef enum { VIR_NETWORK_TAINT_HOOK, /* Hook script was executed over network. We can't guarantee connectivity or other settings @@ -307,7 +307,7 @@ enum virNetworkTaintFlags { */ VIR_NETWORK_TAINT_LAST -}; +} virNetworkTaintFlags; static inline int virNetworkObjIsActive(const virNetworkObj *net) @@ -316,7 +316,7 @@ virNetworkObjIsActive(const virNetworkObj *net) } bool virNetworkObjTaint(virNetworkObjPtr obj, - enum virNetworkTaintFlags taint); + virNetworkTaintFlags taint); virNetworkObjPtr virNetworkFindByUUID(virNetworkObjListPtr nets, const unsigned char *uuid); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 4e8375d..ee8e8a0 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -116,7 +116,7 @@ static int networkUnplugBandwidth(virNetworkObjPtr net, virDomainNetDefPtr iface); static void networkNetworkObjTaint(virNetworkObjPtr net, - enum virNetworkTaintFlags taint); + virNetworkTaintFlags taint); static virNetworkDriverStatePtr driverState = NULL; @@ -4532,7 +4532,7 @@ networkUnplugBandwidth(virNetworkObjPtr net, static void networkNetworkObjTaint(virNetworkObjPtr net, - enum virNetworkTaintFlags taint) + virNetworkTaintFlags taint) { if (virNetworkObjTaint(net, taint)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; -- 1.7.10.4

On 04/27/2014 06:15 PM, Julio Faracco wrote:
In "src/conf/" there are many enumeration (enum) structures like "src/util" directory. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future. Most of the files changed in this commit included Network (network_conf.* and interface_conf.*) enum structures.
Similar commit message tweaks.
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/conf/interface_conf.c | 2 +- src/conf/interface_conf.h | 26 +++++++++++++------------- src/conf/network_conf.c | 2 +- src/conf/network_conf.h | 14 +++++++------- src/network/bridge_driver.c | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-)
ACK and pushed -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

In "src/conf/" there are many enumeration (enum) structures like "src/util" directory, for example. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future. Most of the files changed in this commit included Network Filter (nwfilter.*) enum structures. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/conf/node_device_conf.h | 24 ++++++++++++------------ src/conf/nwfilter_params.c | 2 +- src/conf/nwfilter_params.h | 14 +++++++------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 9b5d172..50e6805 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -35,7 +35,7 @@ # define CREATE_DEVICE 1 # define EXISTING_DEVICE 0 -enum virNodeDevCapType { +typedef enum { /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */ VIR_NODE_DEV_CAP_SYSTEM, /* System capability */ VIR_NODE_DEV_CAP_PCI_DEV, /* PCI device */ @@ -51,38 +51,38 @@ enum virNodeDevCapType { VIR_NODE_DEV_CAP_SCSI_GENERIC, /* SCSI generic device */ VIR_NODE_DEV_CAP_LAST -}; +} virNodeDevCapType; -enum virNodeDevNetCapType { +typedef enum { /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */ VIR_NODE_DEV_CAP_NET_80203, /* 802.03 network device */ VIR_NODE_DEV_CAP_NET_80211, /* 802.11 network device */ VIR_NODE_DEV_CAP_NET_LAST -}; +} virNodeDevNetCapType; VIR_ENUM_DECL(virNodeDevCap) VIR_ENUM_DECL(virNodeDevNetCap) -enum virNodeDevStorageCapFlags { +typedef enum { VIR_NODE_DEV_CAP_STORAGE_REMOVABLE = (1 << 0), VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE = (1 << 1), VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE = (1 << 2), -}; +} virNodeDevStorageCapFlags; -enum virNodeDevSCSIHostCapFlags { +typedef enum { VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST = (1 << 0), VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS = (1 << 1), -}; +} virNodeDevSCSIHostCapFlags; -enum virNodeDevPCICapFlags { +typedef enum { VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION = (1 << 0), VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION = (1 << 1), -}; +} virNodeDevPCICapFlags; typedef struct _virNodeDevCapsDef virNodeDevCapsDef; typedef virNodeDevCapsDef *virNodeDevCapsDefPtr; struct _virNodeDevCapsDef { - enum virNodeDevCapType type; + virNodeDevCapType type; union _virNodeDevCapData { struct { char *product_name; @@ -135,7 +135,7 @@ struct _virNodeDevCapsDef { char *address; unsigned int address_len; char *ifname; - enum virNodeDevNetCapType subtype; /* LAST -> no subtype */ + virNodeDevNetCapType subtype; /* LAST -> no subtype */ } net; struct { unsigned int host; diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c index ac4d4a8..a12e645 100644 --- a/src/conf/nwfilter_params.c +++ b/src/conf/nwfilter_params.c @@ -1061,7 +1061,7 @@ virNWFilterVarAccessGetVarName(const virNWFilterVarAccess *vap) return vap->varName; } -enum virNWFilterVarAccessType +virNWFilterVarAccessType virNWFilterVarAccessGetType(const virNWFilterVarAccess *vap) { return vap->accessType; diff --git a/src/conf/nwfilter_params.h b/src/conf/nwfilter_params.h index 08e448f..98610a7 100644 --- a/src/conf/nwfilter_params.h +++ b/src/conf/nwfilter_params.h @@ -27,17 +27,17 @@ # include "virbuffer.h" # include "virmacaddr.h" -enum virNWFilterVarValueType { +typedef enum { NWFILTER_VALUE_TYPE_SIMPLE, NWFILTER_VALUE_TYPE_ARRAY, NWFILTER_VALUE_TYPE_LAST -}; +} virNWFilterVarValueType; typedef struct _virNWFilterVarValue virNWFilterVarValue; typedef virNWFilterVarValue *virNWFilterVarValuePtr; struct _virNWFilterVarValue { - enum virNWFilterVarValueType valType; + virNWFilterVarValueType valType; union { struct { char *value; @@ -98,17 +98,17 @@ bool virNWFilterHashTableEqual(virNWFilterHashTablePtr a, # define NWFILTER_VARNAME_CTRL_IP_LEARNING "CTRL_IP_LEARNING" # define NWFILTER_VARNAME_DHCPSERVER "DHCPSERVER" -enum virNWFilterVarAccessType { +typedef enum { VIR_NWFILTER_VAR_ACCESS_ELEMENT = 0, VIR_NWFILTER_VAR_ACCESS_ITERATOR = 1, VIR_NWFILTER_VAR_ACCESS_LAST, -}; +} virNWFilterVarAccessType; typedef struct _virNWFilterVarAccess virNWFilterVarAccess; typedef virNWFilterVarAccess *virNWFilterVarAccessPtr; struct _virNWFilterVarAccess { - enum virNWFilterVarAccessType accessType; + virNWFilterVarAccessType accessType; union { struct { unsigned int index; @@ -128,7 +128,7 @@ virNWFilterVarAccessPtr virNWFilterVarAccessParse(const char *varAccess); void virNWFilterVarAccessPrint(virNWFilterVarAccessPtr vap, virBufferPtr buf); const char *virNWFilterVarAccessGetVarName(const virNWFilterVarAccess *vap); -enum virNWFilterVarAccessType virNWFilterVarAccessGetType( +virNWFilterVarAccessType virNWFilterVarAccessGetType( const virNWFilterVarAccess *vap); unsigned int virNWFilterVarAccessGetIterId(const virNWFilterVarAccess *vap); unsigned int virNWFilterVarAccessGetIndex(const virNWFilterVarAccess *vap); -- 1.7.10.4

On 04/27/2014 06:15 PM, Julio Faracco wrote:
In "src/conf/" there are many enumeration (enum) structures like "src/util" directory, for example. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future. Most of the files changed in this commit included Network Filter (nwfilter.*) enum structures.
Long lines again.
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/conf/node_device_conf.h | 24 ++++++++++++------------ src/conf/nwfilter_params.c | 2 +- src/conf/nwfilter_params.h | 14 +++++++------- 3 files changed, 20 insertions(+), 20 deletions(-)
Fails to compile: CC nwfilter/libvirt_driver_nwfilter_impl_la-nwfilter_gentech_driver.lo node_device/node_device_udev.c:1172:24: error: 'enum virNodeDevCapType' declared inside parameter list [-Werror] enum virNodeDevCapType *type) ^ node_device/node_device_udev.c:1172:24: error: its scope is only this definition or declaration, which is probably not what you want [-Werror] node_device/node_device_udev.c: In function 'udevGetDeviceType': node_device/node_device_udev.c:1179:5: error: dereferencing pointer to incomplete type *type = 0; ^ Can you please rebase this patch, then fix and resubmit it? Ask if you need help figuring out how to use 'git rebase -i' (the IRC channel might get you a bit more of a realtime response, if you need it). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

It's strange. Sure, Eric. I will check why it failed to compile. No threre is no problem with "git rebase -i". But If I need some help I will ask you in IRC. Thanks! -- Julio Cesar Faracco

In "src/conf/" there are many enumeration (enum) structures like "src/util" directory, for example. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future. Most of the files changed in this commit included more Network Filter (nwfilter_conf.*) enum structures. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/conf/nwfilter_conf.c | 36 ++++++++++++++++++------------------ src/conf/nwfilter_conf.h | 44 ++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index b332f0f..41b821d 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -448,7 +448,7 @@ union data { unsigned int ui; }; -typedef bool (*valueValidator)(enum attrDatatype datatype, union data *valptr, +typedef bool (*valueValidator)(attrDatatype datatype, union data *valptr, virNWFilterRuleDefPtr nwf, nwItemDesc *item); typedef bool (*valueFormatter)(virBufferPtr buf, @@ -459,7 +459,7 @@ typedef struct _virXMLAttr2Struct virXMLAttr2Struct; struct _virXMLAttr2Struct { const char *name; /* attribute name */ - enum attrDatatype datatype; + attrDatatype datatype; int dataIdx; /* offset of the hasXYZ boolean */ valueValidator validator; /* beyond-standard checkers */ valueFormatter formatter; /* beyond-standard formatter */ @@ -478,7 +478,7 @@ static const struct int_map macProtoMap[] = { static bool -checkMacProtocolID(enum attrDatatype datatype, union data *value, +checkMacProtocolID(attrDatatype datatype, union data *value, virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED, nwItemDesc *item ATTRIBUTE_UNUSED) { @@ -528,7 +528,7 @@ macProtocolIDFormatter(virBufferPtr buf, static bool -checkVlanVlanID(enum attrDatatype datatype, union data *value, +checkVlanVlanID(attrDatatype datatype, union data *value, virNWFilterRuleDefPtr nwf, nwItemDesc *item ATTRIBUTE_UNUSED) { @@ -549,7 +549,7 @@ checkVlanVlanID(enum attrDatatype datatype, union data *value, } static bool -checkVlanProtocolID(enum attrDatatype datatype, union data *value, +checkVlanProtocolID(attrDatatype datatype, union data *value, virNWFilterRuleDefPtr nwf, nwItemDesc *item ATTRIBUTE_UNUSED) { @@ -626,7 +626,7 @@ checkValidMask(unsigned char *data, int len) static bool -checkMACMask(enum attrDatatype datatype ATTRIBUTE_UNUSED, +checkMACMask(attrDatatype datatype ATTRIBUTE_UNUSED, union data *macMask, virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED, nwItemDesc *item ATTRIBUTE_UNUSED) @@ -653,7 +653,7 @@ static const struct int_map arpOpcodeMap[] = { static bool -arpOpcodeValidator(enum attrDatatype datatype, +arpOpcodeValidator(attrDatatype datatype, union data *value, virNWFilterRuleDefPtr nwf, nwItemDesc *item ATTRIBUTE_UNUSED) @@ -715,7 +715,7 @@ static const struct int_map ipProtoMap[] = { static bool -checkIPProtocolID(enum attrDatatype datatype, +checkIPProtocolID(attrDatatype datatype, union data *value, virNWFilterRuleDefPtr nwf, nwItemDesc *item ATTRIBUTE_UNUSED) @@ -763,7 +763,7 @@ formatIPProtocolID(virBufferPtr buf, static bool -dscpValidator(enum attrDatatype datatype, union data *val, +dscpValidator(attrDatatype datatype, union data *val, virNWFilterRuleDefPtr nwf, nwItemDesc *item ATTRIBUTE_UNUSED) { @@ -875,7 +875,7 @@ virNWFilterPrintStateMatchFlags(virBufferPtr buf, const char *prefix, static bool -stateValidator(enum attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, +stateValidator(attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, virNWFilterRuleDefPtr nwf, nwItemDesc *item) { @@ -920,7 +920,7 @@ static const struct int_map tcpFlags[] = { static bool -tcpFlagsValidator(enum attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, +tcpFlagsValidator(attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED, nwItemDesc *item) { @@ -988,7 +988,7 @@ tcpFlagsFormatter(virBufferPtr buf, } static bool -ipsetValidator(enum attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, +ipsetValidator(attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED, nwItemDesc *item) { @@ -1025,7 +1025,7 @@ ipsetFormatter(virBufferPtr buf, } static bool -ipsetFlagsValidator(enum attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, +ipsetFlagsValidator(attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED, nwItemDesc *item) { const char *errmsg = NULL; @@ -1753,7 +1753,7 @@ typedef struct _virAttributes virAttributes; struct _virAttributes { const char *id; const virXMLAttr2Struct *att; - enum virNWFilterRuleProtocolType prtclType; + virNWFilterRuleProtocolType prtclType; }; #define PROTOCOL_ENTRY(ID, ATT, PRTCLTYPE) \ @@ -1798,8 +1798,8 @@ virNWFilterRuleDetailsParse(xmlNodePtr node, int idx = 0; char *prop; bool found = false; - enum attrDatatype datatype, att_datatypes; - enum virNWFilterEntryItemFlags *flags, match_flag = 0, flags_set = 0; + attrDatatype datatype, att_datatypes; + virNWFilterEntryItemFlags *flags, match_flag = 0, flags_set = 0; nwItemDesc *item; int int_val; unsigned int uint_val; @@ -2449,7 +2449,7 @@ virNWFilterIsValidChainName(const char *chainname) static const char * virNWFilterIsAllowedChain(const char *chainname) { - enum virNWFilterChainSuffixType i; + virNWFilterChainSuffixType i; const char *name; char *msg; virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -3225,7 +3225,7 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf, VIR_WARNINGS_NO_CAST_ALIGN item = (nwItemDesc *)((char *)def + att[i].dataIdx); VIR_WARNINGS_RESET - enum virNWFilterEntryItemFlags flags = item->flags; + virNWFilterEntryItemFlags flags = item->flags; if ((flags & NWFILTER_ENTRY_ITEM_FLAG_EXISTS)) { if (!typeShown) { virBufferAsprintf(buf, "<%s", type); diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 3c7985c..a14b4a1 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -69,11 +69,11 @@ # define MAX_CHAIN_SUFFIX_SIZE 12 -enum virNWFilterEntryItemFlags { +typedef enum { NWFILTER_ENTRY_ITEM_FLAG_EXISTS = 1 << 0, NWFILTER_ENTRY_ITEM_FLAG_IS_NEG = 1 << 1, NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR = 1 << 2, -}; +} virNWFilterEntryItemFlags; # define MAX_COMMENT_LENGTH 256 @@ -86,7 +86,7 @@ enum virNWFilterEntryItemFlags { (((data)->flags) & NWFILTER_ENTRY_ITEM_FLAG_IS_NEG) /* datatypes appearing in rule attributes */ -enum attrDatatype { +typedef enum { DATATYPE_UINT16 = (1 << 0), DATATYPE_UINT8 = (1 << 1), DATATYPE_UINT16_HEX = (1 << 2), @@ -106,7 +106,7 @@ enum attrDatatype { DATATYPE_IPSETFLAGS = (1 << 16), DATATYPE_LAST = (1 << 17), -}; +} attrDatatype; # define NWFILTER_MAC_BGA "01:80:c2:00:00:00" @@ -114,9 +114,9 @@ enum attrDatatype { typedef struct _nwItemDesc nwItemDesc; typedef nwItemDesc *nwItemDescPtr; struct _nwItemDesc { - enum virNWFilterEntryItemFlags flags; + virNWFilterEntryItemFlags flags; virNWFilterVarAccessPtr varAccess; - enum attrDatatype datatype; + attrDatatype datatype; union { virMacAddr macaddr; virSocketAddr ipaddr; @@ -348,7 +348,7 @@ struct _udpliteHdrFilterDef { }; -enum virNWFilterRuleActionType { +typedef enum { VIR_NWFILTER_RULE_ACTION_DROP = 0, VIR_NWFILTER_RULE_ACTION_ACCEPT, VIR_NWFILTER_RULE_ACTION_REJECT, @@ -356,29 +356,29 @@ enum virNWFilterRuleActionType { VIR_NWFILTER_RULE_ACTION_CONTINUE, VIR_NWFILTER_RULE_ACTION_LAST, -}; +} virNWFilterRuleActionType; -enum virNWFilterRuleDirectionType { +typedef enum { VIR_NWFILTER_RULE_DIRECTION_IN = 0, VIR_NWFILTER_RULE_DIRECTION_OUT, VIR_NWFILTER_RULE_DIRECTION_INOUT, VIR_NWFILTER_RULE_DIRECTION_LAST, -}; +} virNWFilterRuleDirectionType; -enum virNWFilterChainPolicyType { +typedef enum { VIR_NWFILTER_CHAIN_POLICY_ACCEPT = 0, VIR_NWFILTER_CHAIN_POLICY_DROP, VIR_NWFILTER_CHAIN_POLICY_LAST, -}; +} virNWFilterChainPolicyType; /* * If adding protocols be sure to update the * virNWFilterRuleIsProtocolXXXX function impls */ -enum virNWFilterRuleProtocolType { +typedef enum { /* Ethernet layer protocols */ VIR_NWFILTER_RULE_PROTOCOL_NONE = 0, VIR_NWFILTER_RULE_PROTOCOL_MAC, @@ -411,15 +411,15 @@ enum virNWFilterRuleProtocolType { VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6, VIR_NWFILTER_RULE_PROTOCOL_LAST -}; +} virNWFilterRuleProtocolType; -enum virNWFilterEbtablesTableType { +typedef enum { VIR_NWFILTER_EBTABLES_TABLE_FILTER = 0, VIR_NWFILTER_EBTABLES_TABLE_NAT, VIR_NWFILTER_EBTABLES_TABLE_BROUTE, VIR_NWFILTER_EBTABLES_TABLE_LAST, -}; +} virNWFilterEbtablesTableType; # define MIN_RULE_PRIORITY -1000 @@ -437,14 +437,14 @@ enum virNWFilterEbtablesTableType { # define NWFILTER_ARP_FILTER_PRI -500 # define NWFILTER_RARP_FILTER_PRI -400 -enum virNWFilterRuleFlags { +typedef enum { RULE_FLAG_NO_STATEMATCH = (1 << 0), RULE_FLAG_STATE_NEW = (1 << 1), RULE_FLAG_STATE_ESTABLISHED = (1 << 2), RULE_FLAG_STATE_RELATED = (1 << 3), RULE_FLAG_STATE_INVALID = (1 << 4), RULE_FLAG_STATE_NONE = (1 << 5), -}; +} virNWFilterRuleFlags; # define IPTABLES_STATE_FLAGS \ @@ -463,10 +463,10 @@ typedef struct _virNWFilterRuleDef virNWFilterRuleDef; typedef virNWFilterRuleDef *virNWFilterRuleDefPtr; struct _virNWFilterRuleDef { virNWFilterRulePriority priority; - enum virNWFilterRuleFlags flags; + virNWFilterRuleFlags flags; int action; /*enum virNWFilterRuleActionType*/ int tt; /*enum virNWFilterRuleDirectionType*/ - enum virNWFilterRuleProtocolType prtclType; + virNWFilterRuleProtocolType prtclType; union { ethHdrFilterDef ethHdrFilter; vlanHdrFilterDef vlanHdrFilter; @@ -508,7 +508,7 @@ struct _virNWFilterEntry { virNWFilterIncludeDef *include; }; -enum virNWFilterChainSuffixType { +typedef enum { VIR_NWFILTER_CHAINSUFFIX_ROOT = 0, VIR_NWFILTER_CHAINSUFFIX_MAC, VIR_NWFILTER_CHAINSUFFIX_VLAN, @@ -519,7 +519,7 @@ enum virNWFilterChainSuffixType { VIR_NWFILTER_CHAINSUFFIX_IPv6, VIR_NWFILTER_CHAINSUFFIX_LAST, -}; +} virNWFilterChainSuffixType; # define VALID_CHAINNAME \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.:-" -- 1.7.10.4

In "src/conf/" there are many enumeration (enum) structures like "src/util" directory, for example. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future. Most of the files changed in this commit included Storage and Snapshot (storage_conf.* and snapshot_conf.*) enum structures. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/conf/snapshot_conf.h | 8 +++---- src/conf/storage_conf.h | 48 +++++++++++++++++++++--------------------- src/qemu/qemu_conf.c | 2 +- src/storage/storage_driver.c | 4 ++-- tools/virsh-pool.c | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 5f74b62..e0b2253 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -29,20 +29,20 @@ /* Items related to snapshot state */ -enum virDomainSnapshotLocation { +typedef enum { VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT = 0, VIR_DOMAIN_SNAPSHOT_LOCATION_NONE, VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL, VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL, VIR_DOMAIN_SNAPSHOT_LOCATION_LAST -}; +} virDomainSnapshotLocation; -enum virDomainSnapshotState { +typedef enum { /* Inherit the VIR_DOMAIN_* states from virDomainState. */ VIR_DOMAIN_DISK_SNAPSHOT = VIR_DOMAIN_LAST, VIR_DOMAIN_SNAPSHOT_STATE_LAST -}; +} virDomainSnapshotState; /* Stores disk-snapshot information */ typedef struct _virDomainSnapshotDiskDef virDomainSnapshotDiskDef; diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 9ad38e1..895155d 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -79,7 +79,7 @@ struct _virStorageVolDefList { VIR_ENUM_DECL(virStorageVol) -enum virStoragePoolType { +typedef enum { VIR_STORAGE_POOL_DIR, /* Local directory */ VIR_STORAGE_POOL_FS, /* Local filesystem */ VIR_STORAGE_POOL_NETFS, /* Networked filesystem - eg NFS, GFS, etc */ @@ -93,25 +93,25 @@ enum virStoragePoolType { VIR_STORAGE_POOL_GLUSTER, /* Gluster device */ VIR_STORAGE_POOL_LAST, -}; +} virStoragePoolType; VIR_ENUM_DECL(virStoragePool) -enum virStoragePoolDeviceType { +typedef enum { VIR_STORAGE_DEVICE_TYPE_DISK = 0x00, VIR_STORAGE_DEVICE_TYPE_ROM = 0x05, VIR_STORAGE_DEVICE_TYPE_LAST, -}; +} virStoragePoolDeviceType; -enum virStoragePoolAuthType { +typedef enum { VIR_STORAGE_POOL_AUTH_NONE, VIR_STORAGE_POOL_AUTH_CHAP, VIR_STORAGE_POOL_AUTH_CEPHX, VIR_STORAGE_POOL_AUTH_LAST, -}; +} virStoragePoolAuthType; VIR_ENUM_DECL(virStoragePoolAuthType) typedef struct _virStoragePoolAuthSecret virStoragePoolAuthSecret; @@ -151,12 +151,12 @@ struct _virStoragePoolSourceHost { * For MSDOS partitions, the free area is important when * creating logical partitions */ -enum virStorageFreeType { +typedef enum { VIR_STORAGE_FREE_NONE = 0, VIR_STORAGE_FREE_NORMAL, VIR_STORAGE_FREE_LOGICAL, VIR_STORAGE_FREE_LAST -}; +} virStorageFreeType; /* * Available extents on the underlying storage @@ -196,13 +196,13 @@ struct _virStoragePoolSourceDevice { } geometry; }; -enum virStoragePoolSourceAdapterType { +typedef enum { VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_DEFAULT = 0, VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST, VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST, VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_LAST, -}; +} virStoragePoolSourceAdapterType; VIR_ENUM_DECL(virStoragePoolSourceAdapterType) typedef struct _virStoragePoolSourceAdapter virStoragePoolSourceAdapter; @@ -419,7 +419,7 @@ void virStoragePoolObjLock(virStoragePoolObjPtr obj); void virStoragePoolObjUnlock(virStoragePoolObjPtr obj); -enum virStoragePoolFormatFileSystem { +typedef enum { VIR_STORAGE_POOL_FS_AUTO = 0, VIR_STORAGE_POOL_FS_EXT2, VIR_STORAGE_POOL_FS_EXT3, @@ -434,19 +434,19 @@ enum virStoragePoolFormatFileSystem { VIR_STORAGE_POOL_FS_XFS, VIR_STORAGE_POOL_FS_OCFS2, VIR_STORAGE_POOL_FS_LAST, -}; +} virStoragePoolFormatFileSystem; VIR_ENUM_DECL(virStoragePoolFormatFileSystem) -enum virStoragePoolFormatFileSystemNet { +typedef enum { VIR_STORAGE_POOL_NETFS_AUTO = 0, VIR_STORAGE_POOL_NETFS_NFS, VIR_STORAGE_POOL_NETFS_GLUSTERFS, VIR_STORAGE_POOL_NETFS_CIFS, VIR_STORAGE_POOL_NETFS_LAST, -}; +} virStoragePoolFormatFileSystemNet; VIR_ENUM_DECL(virStoragePoolFormatFileSystemNet) -enum virStoragePoolFormatDisk { +typedef enum { VIR_STORAGE_POOL_DISK_UNKNOWN = 0, VIR_STORAGE_POOL_DISK_DOS = 1, VIR_STORAGE_POOL_DISK_DVH, @@ -457,14 +457,14 @@ enum virStoragePoolFormatDisk { VIR_STORAGE_POOL_DISK_SUN, VIR_STORAGE_POOL_DISK_LVM2, VIR_STORAGE_POOL_DISK_LAST, -}; +} virStoragePoolFormatDisk; VIR_ENUM_DECL(virStoragePoolFormatDisk) -enum virStoragePoolFormatLogical { +typedef enum { VIR_STORAGE_POOL_LOGICAL_UNKNOWN = 0, VIR_STORAGE_POOL_LOGICAL_LVM2 = 1, VIR_STORAGE_POOL_LOGICAL_LAST, -}; +} virStoragePoolFormatLogical; VIR_ENUM_DECL(virStoragePoolFormatLogical) /* @@ -476,7 +476,7 @@ VIR_ENUM_DECL(virStoragePoolFormatLogical) * * So this is a semi-generic set */ -enum virStorageVolFormatDisk { +typedef enum { VIR_STORAGE_VOL_DISK_NONE = 0, VIR_STORAGE_VOL_DISK_LINUX, VIR_STORAGE_VOL_DISK_FAT16, @@ -486,22 +486,22 @@ enum virStorageVolFormatDisk { VIR_STORAGE_VOL_DISK_LINUX_RAID, VIR_STORAGE_VOL_DISK_EXTENDED, VIR_STORAGE_VOL_DISK_LAST, -}; +} virStorageVolFormatDisk; VIR_ENUM_DECL(virStorageVolFormatDisk) -enum virStorageVolTypeDisk { +typedef enum { VIR_STORAGE_VOL_DISK_TYPE_NONE = 0, VIR_STORAGE_VOL_DISK_TYPE_PRIMARY, VIR_STORAGE_VOL_DISK_TYPE_LOGICAL, VIR_STORAGE_VOL_DISK_TYPE_EXTENDED, VIR_STORAGE_VOL_DISK_TYPE_LAST, -}; +} virStorageVolTypeDisk; /* * Mapping of Parted fs-types MUST be kept in the * same order as virStorageVolFormatDisk */ -enum virStoragePartedFsType { +typedef enum { VIR_STORAGE_PARTED_FS_TYPE_NONE = 0, VIR_STORAGE_PARTED_FS_TYPE_LINUX, VIR_STORAGE_PARTED_FS_TYPE_FAT16, @@ -511,7 +511,7 @@ enum virStoragePartedFsType { VIR_STORAGE_PARTED_FS_TYPE_LINUX_RAID, VIR_STORAGE_PARTED_FS_TYPE_EXTENDED, VIR_STORAGE_PARTED_FS_TYPE_LAST, -}; +} virStoragePartedFsType; VIR_ENUM_DECL(virStoragePartedFsType) # define VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE \ diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 198ee2f..b0dab59 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1312,7 +1312,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, virStorageNetHostDefFree(def->src.nhosts, def->src.hosts); virStorageSourceAuthClear(&def->src); - switch ((enum virStoragePoolType) pooldef->type) { + switch ((virStoragePoolType) pooldef->type) { case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_FS: case VIR_STORAGE_POOL_NETFS: diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 2cb8347..01ed1bf 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1483,7 +1483,7 @@ storageVolLookupByPath(virConnectPtr conn, continue; } - switch ((enum virStoragePoolType) pool->def->type) { + switch ((virStoragePoolType) pool->def->type) { case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_FS: case VIR_STORAGE_POOL_NETFS: @@ -2083,7 +2083,7 @@ storageVolUpload(virStorageVolPtr obj, goto cleanup; } - switch ((enum virStoragePoolType) pool->def->type) { + switch ((virStoragePoolType) pool->def->type) { case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_FS: case VIR_STORAGE_POOL_NETFS: diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 0d35cf5..7c40b5b 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1029,7 +1029,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) return false; } - switch ((enum virStoragePoolType) poolType) { + switch ((virStoragePoolType) poolType) { case VIR_STORAGE_POOL_DIR: flags |= VIR_CONNECT_LIST_STORAGE_POOLS_DIR; break; -- 1.7.10.4

On 04/27/2014 06:15 PM, Julio Faracco wrote:
In "src/conf/" there are many enumeration (enum) structures like "src/util" directory. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future.
Again, long subject and commit message contents, so I tweaked them.
Most of the files changed in this commit included CPU (cpu_conf) enum structures.
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- src/conf/cpu_conf.c | 2 +- src/conf/cpu_conf.h | 22 +++++++++++----------- src/conf/device_conf.h | 4 ++-- src/cpu/cpu_powerpc.c | 2 +- src/cpu/cpu_x86.c | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-)
ACK and pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Julio Faracco