From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> The virDomainNetGetActualBridgeName and virDomainNetGetActualDirectDev methods both return strings that point to data in the virDomainDefPtr struct, and should therefore not be freed. The return values should thus be 'const char *' not 'char *'. * src/conf/domain_conf.c, src/conf/domain_conf.h: Mark const * src/network/bridge_driver.c: Update to use a const char * --- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 4 ++-- src/network/bridge_driver.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9528697..5a83dec 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13046,7 +13046,7 @@ virDomainNetGetActualType(virDomainNetDefPtr iface) return iface->data.network.actual->type; } -char * +const char * virDomainNetGetActualBridgeName(virDomainNetDefPtr iface) { if (iface->type == VIR_DOMAIN_NET_TYPE_BRIDGE) @@ -13058,7 +13058,7 @@ virDomainNetGetActualBridgeName(virDomainNetDefPtr iface) return iface->data.network.actual->data.bridge.brname; } -char * +const char * virDomainNetGetActualDirectDev(virDomainNetDefPtr iface) { if (iface->type == VIR_DOMAIN_NET_TYPE_DIRECT) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9528199..4e86d30 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1794,8 +1794,8 @@ int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def, ATTRIBUTE_NONNULL(1); int virDomainNetGetActualType(virDomainNetDefPtr iface); -char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); -char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface); +const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); +const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface); int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface); virNetDevVPortProfilePtr virDomainNetGetActualDirectVirtPortProfile(virDomainNetDefPtr iface); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 5dfc294..623e4b3 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2898,7 +2898,7 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) struct network_driver *driver = driverState; virNetworkObjPtr network; virNetworkDefPtr netdef; - char *actualDev; + const char *actualDev; int ret = -1; if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) @@ -2924,8 +2924,8 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) if (!actualDev) { networkReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("the interface uses a direct mode, but has no source dev")); - goto cleanup; - } + goto cleanup; + } netdef = network->def; if (netdef->nForwardIfs == 0) { @@ -2998,7 +2998,7 @@ networkReleaseActualDevice(virDomainNetDefPtr iface) struct network_driver *driver = driverState; virNetworkObjPtr network = NULL; virNetworkDefPtr netdef; - char *actualDev; + const char *actualDev; int ret = -1; if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) @@ -3025,8 +3025,8 @@ networkReleaseActualDevice(virDomainNetDefPtr iface) if (!actualDev) { networkReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("the interface uses a direct mode, but has no source dev")); - goto cleanup; - } + goto cleanup; + } netdef = network->def; if (netdef->nForwardIfs == 0) { -- 1.7.6.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list