[libvirt] [PATCH 1/4] conf: use typedefs for enums in "src/conf/{node_device_conf, nwfilter_params}.h"

In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are reltaed to Network (node_device_conf.h and nwfilter_params.*) enums. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.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

In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are related to network filter (nwfilter_conf) enums. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.com> --- src/conf/nwfilter_conf.c | 8 ++++---- src/conf/nwfilter_conf.h | 44 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index b9f6d51..c675967 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -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) \ @@ -1799,7 +1799,7 @@ virNWFilterRuleDetailsParse(xmlNodePtr node, char *prop; bool found = false; enum attrDatatype datatype, att_datatypes; - enum virNWFilterEntryItemFlags *flags, match_flag = 0, flags_set = 0; + virNWFilterEntryItemFlags *flags, match_flag = 0, flags_set = 0; nwItemDesc *item; int int_val; unsigned int uint_val; @@ -2511,7 +2511,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; @@ -3287,7 +3287,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..79116b1 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 @@ -114,7 +114,7 @@ enum attrDatatype { typedef struct _nwItemDesc nwItemDesc; typedef nwItemDesc *nwItemDescPtr; struct _nwItemDesc { - enum virNWFilterEntryItemFlags flags; + virNWFilterEntryItemFlags flags; virNWFilterVarAccessPtr varAccess; enum attrDatatype datatype; union { @@ -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_.:-" @@ -577,16 +577,16 @@ struct _virNWFilterDriverState { }; -enum UpdateStep { +typedef enum { STEP_APPLY_NEW, STEP_TEAR_NEW, STEP_TEAR_OLD, STEP_APPLY_CURRENT, -}; +} UpdateStep; struct domUpdateCBStruct { void *opaque; - enum UpdateStep step; + UpdateStep step; virHashTablePtr skipInterfaces; }; -- 1.7.10.4

On 05/11/2014 09:08 AM, Julio Faracco wrote:
In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are related to network filter (nwfilter_conf) enums.
Rewrapped,
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.com> --- src/conf/nwfilter_conf.c | 8 ++++---- src/conf/nwfilter_conf.h | 44 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 26 deletions(-)
ACK and applied. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are related to storage (storage_conf) enums. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.com> --- src/conf/storage_conf.h | 48 +++++++++++++++++++++--------------------- src/qemu/qemu_conf.c | 2 +- src/storage/storage_driver.c | 4 ++-- tools/virsh-pool.c | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index eae959c..8c3bc57 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -80,7 +80,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 */ @@ -94,25 +94,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; @@ -152,12 +152,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 @@ -197,13 +197,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; @@ -420,7 +420,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, @@ -435,19 +435,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, @@ -458,14 +458,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) /* @@ -477,7 +477,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, @@ -487,22 +487,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, @@ -512,7 +512,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 e487f5e..400c99c 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1316,7 +1316,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 67494a3..f58e0a4 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: @@ -2096,7 +2096,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 05/11/2014 09:08 AM, Julio Faracco wrote:
In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are related to storage (storage_conf) enums.
Rewrapped,
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.com> --- src/conf/storage_conf.h | 48 +++++++++++++++++++++--------------------- src/qemu/qemu_conf.c | 2 +- src/storage/storage_driver.c | 4 ++-- tools/virsh-pool.c | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-)
I also updated the patch to clean up lots of comments. (Hmm, util/virstoragefile.h would be another candidate for a cleanup). ACK and pushed as amended: diff --git i/src/conf/domain_conf.h w/src/conf/domain_conf.h index a92f0f3..63c4577 100644 --- i/src/conf/domain_conf.h +++ w/src/conf/domain_conf.h @@ -607,7 +607,7 @@ struct _virDomainDiskDef { int removable; /* enum virDomainFeatureState */ char *mirror; - int mirrorFormat; /* enum virStorageFileFormat */ + int mirrorFormat; /* virStorageFileFormat */ bool mirroring; struct { @@ -776,7 +776,7 @@ struct _virDomainFSDef { int fsdriver; /* enum virDomainFSDriverType */ int accessmode; /* enum virDomainFSAccessMode */ int wrpolicy; /* enum virDomainFSWrpolicy */ - int format; /* enum virStorageFileFormat */ + int format; /* virStorageFileFormat */ unsigned long long usage; /* in bytes */ char *src; char *dst; diff --git i/src/conf/storage_conf.h w/src/conf/storage_conf.h index 8c3bc57..b10d4f2 100644 --- i/src/conf/storage_conf.h +++ w/src/conf/storage_conf.h @@ -51,7 +51,7 @@ struct _virStorageVolSource { int nextent; virStorageVolSourceExtentPtr extents; - int partType; /* enum virStorageVolTypeDisk, only used by disk + int partType; /* virStorageVolTypeDisk, only used by disk * backend for partition type creation */ }; @@ -61,7 +61,7 @@ typedef virStorageVolDef *virStorageVolDefPtr; struct _virStorageVolDef { char *name; char *key; - int type; /* enum virStorageVolType */ + int type; /* virStorageVolType */ unsigned int building; unsigned int in_use; @@ -167,7 +167,7 @@ typedef virStoragePoolSourceDeviceExtent *virStoragePoolSourceDeviceExtentPtr; struct _virStoragePoolSourceDeviceExtent { unsigned long long start; unsigned long long end; - int type; /* enum virStorageFreeType */ + int type; /* virStorageFreeType */ }; typedef struct _virStoragePoolSourceInitiatorAttr virStoragePoolSourceInitiatorAttr; @@ -208,7 +208,7 @@ VIR_ENUM_DECL(virStoragePoolSourceAdapterType) typedef struct _virStoragePoolSourceAdapter virStoragePoolSourceAdapter; struct _virStoragePoolSourceAdapter { - int type; /* enum virStoragePoolSourceAdapterType */ + int type; /* virStoragePoolSourceAdapterType */ union { char *name; @@ -273,7 +273,7 @@ typedef virStoragePoolDef *virStoragePoolDefPtr; struct _virStoragePoolDef { char *name; unsigned char uuid[VIR_UUID_BUFLEN]; - int type; /* enum virStoragePoolType */ + int type; /* virStoragePoolType */ unsigned long long allocation; /* bytes */ unsigned long long capacity; /* bytes */ diff --git i/src/util/virstoragefile.h w/src/util/virstoragefile.h index 6072409..e32389e 100644 --- i/src/util/virstoragefile.h +++ w/src/util/virstoragefile.h @@ -150,7 +150,7 @@ typedef virStorageNetHostDef *virStorageNetHostDefPtr; struct _virStorageNetHostDef { char *name; char *port; - int transport; /* enum virStorageNetHostTransport */ + int transport; /* virStorageNetHostTransport */ char *socket; /* path to unix socket */ }; @@ -182,10 +182,10 @@ typedef struct _virStorageSourcePoolDef virStorageSourcePoolDef; struct _virStorageSourcePoolDef { char *pool; /* pool name */ char *volume; /* volume name */ - int voltype; /* enum virStorageVolType, internal only */ - int pooltype; /* enum virStoragePoolType, internal only */ - int actualtype; /* enum virStorageType, internal only */ - int mode; /* enum virStorageSourcePoolMode */ + int voltype; /* virStorageVolType, internal only */ + int pooltype; /* virStoragePoolType, internal only */ + int actualtype; /* virStorageType, internal only */ + int mode; /* virStorageSourcePoolMode */ }; typedef virStorageSourcePoolDef *virStorageSourcePoolDefPtr; @@ -208,15 +208,15 @@ typedef virStorageSource *virStorageSourcePtr; * backing chains, multiple source disks join to form a single guest * view. */ struct _virStorageSource { - int type; /* enum virStorageType */ + int type; /* virStorageType */ char *path; - int protocol; /* enum virStorageNetProtocol */ + int protocol; /* virStorageNetProtocol */ size_t nhosts; virStorageNetHostDefPtr hosts; virStorageSourcePoolDefPtr srcpool; struct { char *username; - int secretType; /* enum virStorageSecretType */ + int secretType; /* virStorageSecretType */ union { unsigned char uuid[VIR_UUID_BUFLEN]; char *usage; @@ -225,7 +225,7 @@ struct _virStorageSource { virStorageEncryptionPtr encryption; char *driverName; - int format; /* enum virStorageFileFormat */ + int format; /* virStorageFileFormat */ virBitmapPtr features; char *compat; -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are related to snapshot (snapshot_conf) enums. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.com> --- src/conf/snapshot_conf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 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; -- 1.7.10.4

On 05/11/2014 09:08 AM, Julio Faracco wrote:
In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are related to snapshot (snapshot_conf) enums.
Wrapped,
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.com> --- src/conf/snapshot_conf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
ACK and pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Sun, May 11, 2014 at 8:38 PM, Julio Faracco <jcfaracco@gmail.com> wrote:
In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are reltaed to Network (node_device_conf.h and nwfilter_params.*) enums.
s/reltaed/related Same typo in the commit message in 6000705ab191d91adf77b65ce7e4ff63b0582462. Don't wanna repeat again. Please cut your commit message length, as Eric had mentioned in https://www.redhat.com/archives/libvir-list/2014-April/msg01134.html Regards, Nehal J Wani

On 05/11/2014 09:08 AM, Julio Faracco wrote: When sending a series, it helps to use 'git send-email --cover-letter' (or 'git format-patch --cover-letter' before regular 'git send-email') to generate the 0/N lead-in letter. Mail client threading is easier when all patches are in-reply to the 0/N cover letter than when patches 2-N are in-reply to patch 1. For example, my client sorts all replies to the same message in the order received. Look what happens with a cover letter: 0/4 + 1/4 | + Re: 1/4 + 2/4 | + Re: 2/4 + 3/4 | + Re: 3/4 + 3/4 + Re: 3/4 vs. how hard it is to associate 1/4 with its direct review reply without a cover letter: 1/4 + 2/4 | + Re: 2/4 + 3/4 | + Re: 3/4 + 4/4 | + Re: 4/4 + Re: 1/4
In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are reltaed to Network (node_device_conf.h and nwfilter_params.*) enums.
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Please don't add Signed-off-by: for anyone that did not actively write (part of) the patch or tweak the commit as part of pushing it into an upstream tree. I add Signed-off-by when applying your commits to the tree, to state that I created a new commit hash (even if all I do is 'git am' your patch, that is a different commit id in my tree than in yours, so I have modified things). But until I'm happy enough with the patch to push it upstream, I haven't actually signed off the contents of the patch; at this point in the game, you are sending the patch where only you are responsible for what it looks like. It's okay to mention me in the commit message if I gave you ideas used in the patch, but do that with something like "Suggested by:" rather than "Signed-off-by:". Generally you don't see a second S-o-b for anything that is still pending upstream inclusion unless it was truly a joint authorship situation. [By the way, on this list we are fairly lax about the meaning of S-o-b, or even its omission; although we are gradually morphing more towards the model used by the Linux kernel. On that list, they are absolute sticklers, because they use S-o-b as a legal statement of blame for copyright purposes, while we aren't there yet]
--- 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(-)
So, in spite of all that, your patch itself is fine, so I'm going to amend the commit message to avoid long lines (hey - that means I actually added my S-o-b via my normal policy after all) and push it shortly. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 05/12/2014 03:32 PM, Eric Blake wrote:
On 05/11/2014 09:08 AM, Julio Faracco wrote:
Another helpful action: when resending an updated patch, use 'git send-email --subject-prefix=PATCHv2' to make it obvious in the subject line that it is a resend, then after the '---' separator, add comments explaining why it is better than v1.
In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use 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 are reltaed to Network (node_device_conf.h and nwfilter_params.*) enums.
So, in spite of all that, your patch itself is fine, so I'm going to amend the commit message to avoid long lines (hey - that means I actually added my S-o-b via my normal policy after all) and push it shortly.
Take that back. Your patch STILL fails to compile: CC nwfilter/libvirt_driver_nwfilter_impl_la-nwfilter_ebiptables_driver.lo node_device/node_device_udev.c:1179:24: error: 'enum virNodeDevCapType' declared inside parameter list [-Werror] enum virNodeDevCapType *type) ^ node_device/node_device_udev.c:1179:24: error: its scope is only this definition or declaration, which is probably not what you want [-Werror] Here's what I had to squash before pushing this patch. diff --git i/src/node_device/node_device_hal.c w/src/node_device/node_device_hal.c index 5dbc3eb..8656b5d 100644 --- i/src/node_device/node_device_hal.c +++ w/src/node_device/node_device_hal.c @@ -1,7 +1,7 @@ /* * node_device_hal.c: node device enumeration - HAL-based implementation * - * Copyright (C) 2011, 2013 Red Hat, Inc. + * Copyright (C) 2011-2014 Red Hat, Inc. * Copyright (C) 2008 Virtual Iron Software, Inc. * Copyright (C) 2008 David F. Lively * @@ -343,7 +343,7 @@ gather_system_cap(LibHalContext *ctx, const char *udi, struct _caps_tbl_entry { const char *cap_name; - enum virNodeDevCapType type; + virNodeDevCapType type; int (*gather_fn)(LibHalContext *ctx, const char *udi, union _virNodeDevCapData *data); diff --git i/src/node_device/node_device_udev.c w/src/node_device/node_device_udev.c index d24f2dc..9a951d9 100644 --- i/src/node_device/node_device_udev.c +++ w/src/node_device/node_device_udev.c @@ -1176,7 +1176,7 @@ udevHasDeviceProperty(struct udev_device *dev, static int udevGetDeviceType(struct udev_device *device, - enum virNodeDevCapType *type) + virNodeDevCapType *type) { const char *devtype = NULL; char *subsystem = NULL; -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Nehal: I'm sorry. My fault. When Eric said that I thought that he was talking about the short commit message. Well, now I know that he is talking about the whole commit messages. Eric: Thanks for your help. I'm still familiarizing myself with the rules of the group and patches. It's ok for me to generate a patch and send. But, I didn't know about PATCHv2. I saw it in mailing list. But, I didn't know why someone sent a PATCHv2. Now, I know. =) About, S-o-b. You're right it's better using "Suggested by" instead "S-o-b". My fault again. That sort of thing you only get with practice. Finishing, about the compilation falied, I will check it. I wanna discover why my changes compile successfull and here is not compiling. Thanks everybody! -- Julio Cesar Faracco

On Mon, May 12, 2014 at 04:49:39PM -0600, Eric Blake wrote:
On 05/12/2014 03:32 PM, Eric Blake wrote:
Another helpful action: when resending an updated patch, use 'git send-email --subject-prefix=PATCHv2' to make it obvious in the subject line that it is a resend,
-v2 does the same and is less typing ;) Christophe

On 05/14/2014 02:13 AM, Christophe Fergeau wrote:
On Mon, May 12, 2014 at 04:49:39PM -0600, Eric Blake wrote:
On 05/12/2014 03:32 PM, Eric Blake wrote:
Another helpful action: when resending an updated patch, use 'git send-email --subject-prefix=PATCHv2' to make it obvious in the subject line that it is a resend,
-v2 does the same and is less typing ;)
Wow, learned something new. [I _hate_ that 'git send-email --help' does NOT document the options that it inherits from 'git format-patch'] -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (4)
-
Christophe Fergeau
-
Eric Blake
-
Julio Faracco
-
Nehal J Wani