From: Peter Krempa <pkre...@redhat.com> Convert the member to the appropriate type, fix few offending parse calls and remove explicit typecasts in switch().
Signed-off-by: Peter Krempa <pkre...@redhat.com> --- src/conf/domain_conf.c | 5 +---- src/conf/domain_validate.c | 2 +- src/conf/storage_source_conf.h | 2 +- src/libxl/libxl_conf.c | 2 +- src/libxl/xen_xl.c | 2 +- src/qemu/qemu_block.c | 7 +++---- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_snapshot.c | 4 ++-- .../storage_source_backingstore.c | 21 ++++++++++++------- 9 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1e24e41a48..f1057b406c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7368,15 +7368,12 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, virStorageSource *src, unsigned int flags) { - virStorageNetProtocol protocol; xmlNodePtr tmpnode; if (virXMLPropEnum(node, "protocol", virStorageNetProtocolTypeFromString, - VIR_XML_PROP_REQUIRED, &protocol) < 0) + VIR_XML_PROP_REQUIRED, &src->protocol) < 0) return -1; - src->protocol = protocol; - if (!(src->path = virXMLPropString(node, "name")) && src->protocol != VIR_STORAGE_NET_PROTOCOL_NBD) { virReportError(VIR_ERR_XML_ERROR, "%s", diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b28af7fa56..87fbefe4f1 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -494,7 +494,7 @@ virDomainDiskDefValidateSourceChainOne(const virStorageSource *src) return -1; } - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_ISCSI: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index ebddf28cd6..362897f058 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -301,7 +301,7 @@ struct _virStorageSource { virStorageType type; char *path; char *fdgroup; /* name of group of file descriptors the user wishes to use instead of 'path' */ - int protocol; /* virStorageNetProtocol */ + virStorageNetProtocol protocol; char *volume; /* volume name for remote storage */ char *snapshot; /* for storage systems supporting internal snapshots */ char *configFile; /* some storage systems use config file as part of diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index bdd30dd65a..36fba4a555 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1068,7 +1068,7 @@ libxlMakeNetworkDiskSrcStr(virStorageSource *src, g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; size_t i; - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index ec8de30c01..b83ed45c46 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1448,7 +1448,7 @@ xenFormatXLDiskSrcNet(virStorageSource *src) g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; size_t i; - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 32568d4ae6..a59c0a0a03 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1046,14 +1046,13 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src, break; } - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: driver = "gluster"; if (!(fileprops = qemuBlockStorageSourceGetGlusterProps(src, onlytarget))) return NULL; break; - case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: case VIR_STORAGE_NET_PROTOCOL_FTP: @@ -1969,7 +1968,7 @@ qemuBlockGetBackingStoreString(virStorageSource *src, src->readahead == 0 && src->reconnectDelay == 0) { - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: @@ -2352,7 +2351,7 @@ qemuBlockStorageSourceCreateGetStorageProps(virStorageSource *src, break; case VIR_STORAGE_TYPE_NETWORK: - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: driver = "gluster"; if (!(location = qemuBlockStorageSourceGetGlusterProps(src, false))) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0d2548d8d4..cf5083de34 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8943,7 +8943,7 @@ qemuDomainPrepareStorageSourceTLS(virStorageSource *src, if (virStorageSourceGetActualType(src) != VIR_STORAGE_TYPE_NETWORK) return 0; - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_VXHS: /* vxhs is no longer supported */ break; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 8128154749..764aafda4d 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -658,7 +658,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDef *snapdisk, break; case VIR_STORAGE_TYPE_NETWORK: - switch ((virStorageNetProtocol) domdisk->src->protocol) { + switch (domdisk->src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_RBD: @@ -883,7 +883,7 @@ qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, return 0; case VIR_STORAGE_TYPE_NETWORK: - switch ((virStorageNetProtocol) disk->src->protocol) { + switch (disk->src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_RBD: diff --git a/src/storage_file/storage_source_backingstore.c b/src/storage_file/storage_source_backingstore.c index 80681924ea..4a273fe46c 100644 --- a/src/storage_file/storage_source_backingstore.c +++ b/src/storage_file/storage_source_backingstore.c @@ -44,6 +44,7 @@ virStorageSourceParseBackingURI(virStorageSource *src, const char *path = NULL; int transport = 0; g_auto(GStrv) scheme = NULL; + int protocol; if (!(uri = virURIParse(uristr))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -59,12 +60,13 @@ virStorageSourceParseBackingURI(virStorageSource *src, return -1; if (!scheme[0] || - (src->protocol = virStorageNetProtocolTypeFromString(scheme[0])) < 0) { + (protocol = virStorageNetProtocolTypeFromString(scheme[0])) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid backing protocol '%1$s'"), NULLSTR(scheme[0])); return -1; } + src->protocol = protocol; if (scheme[1]) { if ((transport = virStorageNetHostTransportTypeFromString(scheme[1])) < 0) { @@ -370,7 +372,8 @@ virStorageSourceParseBackingColon(virStorageSource *src, const char *path) { const char *p; - g_autofree char *protocol = NULL; + g_autofree char *protocol_str = NULL; + int protocol; if (!(p = strchr(path, ':'))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -379,16 +382,18 @@ virStorageSourceParseBackingColon(virStorageSource *src, return -1; } - protocol = g_strndup(path, p - path); + protocol_str = g_strndup(path, p - path); - if ((src->protocol = virStorageNetProtocolTypeFromString(protocol)) < 0) { + if ((protocol = virStorageNetProtocolTypeFromString(protocol_str)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid backing protocol '%1$s'"), - protocol); + protocol_str); return -1; } - switch ((virStorageNetProtocol) src->protocol) { + src->protocol = protocol; + + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: if (virStorageSourceParseNBDColonString(path, src) < 0) return -1; @@ -404,7 +409,7 @@ virStorageSourceParseBackingColon(virStorageSource *src, case VIR_STORAGE_NET_PROTOCOL_NONE: virReportError(VIR_ERR_INTERNAL_ERROR, _("backing store parser is not implemented for protocol %1$s"), - protocol); + protocol_str); return -1; case VIR_STORAGE_NET_PROTOCOL_HTTP: @@ -419,7 +424,7 @@ virStorageSourceParseBackingColon(virStorageSource *src, case VIR_STORAGE_NET_PROTOCOL_NFS: virReportError(VIR_ERR_INTERNAL_ERROR, _("malformed backing store path for protocol %1$s"), - protocol); + protocol_str); return -1; } -- 2.49.0