[libvirt PATCH v2 3/8] cpu_map: Use g_auto* in loadIncludes

Ján Tomko jtomko at redhat.com
Fri Sep 11 12:55:31 UTC 2020


On a Friday in 2020, Tim Wiederhake wrote:
>Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
>---
> src/cpu/cpu_map.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
>diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
>index 53c8cbba6b..ac98a14e2e 100644
>--- a/src/cpu/cpu_map.c
>+++ b/src/cpu/cpu_map.c
>@@ -125,18 +125,16 @@ loadIncludes(xmlXPathContextPtr ctxt,
>         return -1;
>
>     for (i = 0; i < n; i++) {
>-        char *filename = virXMLPropString(nodes[i], "filename");
>-        if (!filename) {
>+        g_autofree char *filename = NULL;
>+

You can assign to filename right away, there's no need to change the condtion.

>+        if (!(filename = virXMLPropString(nodes[i], "filename"))) {
>             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                            _("Missing 'filename' in CPU map include"));
>             return -1;
>         }
>         VIR_DEBUG("Finding CPU map include '%s'", filename);
>-        if (cpuMapLoadInclude(filename, vendorCB, featureCB, modelCB, data) < 0) {
>-            VIR_FREE(filename);
>+        if (cpuMapLoadInclude(filename, vendorCB, featureCB, modelCB, data) < 0)
>             return -1;
>-        }
>-        VIR_FREE(filename);
>     }
>

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200911/c02b55a6/attachment-0001.sig>


More information about the libvir-list mailing list