diff options
author | Michal Privoznik <mprivozn@redhat.com> | 2022-01-28 18:42:45 +0100 |
---|---|---|
committer | Michal Privoznik <mprivozn@redhat.com> | 2022-02-08 08:42:07 +0100 |
commit | 87a43a907f0ad4897a28ad7c216bc70f37270b93 (patch) | |
tree | 77becc044a219aed11f5522edb39fc8aa3cd66ae /src/vmx | |
parent | 1688d2527f1ae34d57d0b5c01fbea79e40dac7b7 (diff) | |
download | libvirt-87a43a907f0ad4897a28ad7c216bc70f37270b93.tar.gz |
lib: Use g_clear_pointer() more
This change was generated using the following spatch:
@ rule1 @
expression a;
identifier f;
@@
<...
- f(*a);
... when != a;
- *a = NULL;
+ g_clear_pointer(a, f);
...>
@ rule2 @
expression a;
identifier f;
@@
<...
- f(a);
... when != a;
- a = NULL;
+ g_clear_pointer(&a, f);
...>
Then, I left some of the changes out, like tools/nss/ (which
doesn't link with glib) and put back a comment in
qemuBlockJobProcessEventCompletedActiveCommit() which coccinelle
decided to remove (I have no idea why).
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Diffstat (limited to 'src/vmx')
-rw-r--r-- | src/vmx/vmx.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index ca65caa9a1..8150bbfaa9 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1425,8 +1425,7 @@ virVMXParseConfig(virVMXContext *ctx, if (encoding == NULL || STRCASEEQ(encoding, "UTF-8")) { /* nothing */ } else { - virConfFree(conf); - conf = NULL; + g_clear_pointer(&conf, virConfFree); utf8 = virVMXConvertToUTF8(encoding, vmx); @@ -2053,8 +2052,7 @@ virVMXParseVNC(virConf *conf, virDomainGraphicsDef **def) failure: VIR_FREE(listenAddr); - virDomainGraphicsDefFree(*def); - *def = NULL; + g_clear_pointer(def, virDomainGraphicsDefFree); return -1; } @@ -2556,8 +2554,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOption *xmlopt, virConf *conf, cleanup: if (result < 0) { - virDomainDiskDefFree(*def); - *def = NULL; + g_clear_pointer(def, virDomainDiskDefFree); } VIR_FREE(prefix); @@ -2569,8 +2566,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOption *xmlopt, virConf *conf, return result; ignore: - virDomainDiskDefFree(*def); - *def = NULL; + g_clear_pointer(def, virDomainDiskDefFree); result = 0; @@ -2653,8 +2649,7 @@ virVMXParseFileSystem(virConf *conf, int number, virDomainFSDef **def) cleanup: if (result < 0) { - virDomainFSDefFree(*def); - *def = NULL; + g_clear_pointer(def, virDomainFSDefFree); } VIR_FREE(hostPath); @@ -2869,8 +2864,7 @@ virVMXParseEthernet(virConf *conf, int controller, virDomainNetDef **def) cleanup: if (result < 0) { - virDomainNetDefFree(*def); - *def = NULL; + g_clear_pointer(def, virDomainNetDefFree); } VIR_FREE(networkName); @@ -3051,8 +3045,7 @@ virVMXParseSerial(virVMXContext *ctx, virConf *conf, int port, cleanup: if (result < 0) { - virDomainChrDefFree(*def); - *def = NULL; + g_clear_pointer(def, virDomainChrDefFree); } VIR_FREE(fileType); @@ -3153,8 +3146,7 @@ virVMXParseParallel(virVMXContext *ctx, virConf *conf, int port, cleanup: if (result < 0) { - virDomainChrDefFree(*def); - *def = NULL; + g_clear_pointer(def, virDomainChrDefFree); } VIR_FREE(fileType); @@ -3191,8 +3183,7 @@ virVMXParseSVGA(virConf *conf, virDomainVideoDef **def) cleanup: if (result < 0) { - virDomainVideoDefFree(*def); - *def = NULL; + g_clear_pointer(def, virDomainVideoDefFree); } return result; |