[libvirt] [PATCH v2 01/32] conf, util, qemu: Use VIR_STEAL_PTR for authdef processing

John Ferlan posted 32 patches 6 years, 12 months ago
There is a newer version of this series
[libvirt] [PATCH v2 01/32] conf, util, qemu: Use VIR_STEAL_PTR for authdef processing
Posted by John Ferlan 6 years, 12 months ago
Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
---
 src/conf/domain_conf.c        | 3 +--
 src/conf/storage_conf.c       | 3 +--
 src/qemu/qemu_parse_command.c | 3 +--
 src/util/virstoragefile.c     | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6772c327ed..a33f18c957 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7632,8 +7632,7 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
                                authdef->secrettype);
                 goto cleanup;
             }
-            iscsisrc->src->auth = authdef;
-            authdef = NULL;
+            VIR_STEAL_PTR(iscsisrc->src->auth, authdef);
         }
         cur = cur->next;
     }
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 1ee31ca676..fbd62e1305 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -584,8 +584,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
             goto cleanup;
         }
 
-        source->auth = authdef;
-        authdef = NULL;
+        VIR_STEAL_PTR(source->auth, authdef);
     }
 
     /* Option protocol version string (NFSvN) */
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index c4650f01e0..679d49d442 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -133,8 +133,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
             if (VIR_STRDUP(authdef->secrettype, secrettype) < 0)
                 goto error;
         }
-        def->src->auth = authdef;
-        authdef = NULL;
+        VIR_STEAL_PTR(def->src->auth, authdef);
 
         /* Cannot formulate a secretType (eg, usage or uuid) given
          * what is provided.
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 8319ba9c8c..98f9bc803f 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2895,9 +2895,8 @@ virStorageSourceParseRBDColonString(const char *rbdstr,
             if (VIR_STRDUP(authdef->secrettype,
                            virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_CEPH)) < 0)
                 goto error;
-            src->auth = authdef;
+            VIR_STEAL_PTR(src->auth, authdef);
             src->authInherited = true;
-            authdef = NULL;
 
             /* Cannot formulate a secretType (eg, usage or uuid) given
              * what is provided.
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 01/32] conf, util, qemu: Use VIR_STEAL_PTR for authdef processing
Posted by Ján Tomko 6 years, 12 months ago
On Fri, Feb 08, 2019 at 01:36:55PM -0500, John Ferlan wrote:
>Signed-off-by: John Ferlan <jferlan@redhat.com>
>Reviewed-by: Erik Skultety <eskultet@redhat.com>
>---
> src/conf/domain_conf.c        | 3 +--
> src/conf/storage_conf.c       | 3 +--
> src/qemu/qemu_parse_command.c | 3 +--
> src/util/virstoragefile.c     | 3 +--
> 4 files changed, 4 insertions(+), 8 deletions(-)
>

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

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 01/32] conf, util, qemu: Use VIR_STEAL_PTR for authdef processing
Posted by Ján Tomko 6 years, 12 months ago
On Fri, Feb 08, 2019 at 01:36:55PM -0500, John Ferlan wrote:
>Signed-off-by: John Ferlan <jferlan@redhat.com>
>Reviewed-by: Erik Skultety <eskultet@redhat.com>
>---
> src/conf/domain_conf.c        | 3 +--
> src/conf/storage_conf.c       | 3 +--
> src/qemu/qemu_parse_command.c | 3 +--
> src/util/virstoragefile.c     | 3 +--
> 4 files changed, 4 insertions(+), 8 deletions(-)
>

NB: in the two cases below, the assignment can be performed multiple
times (e.g. by supplying <auth> multiple times to an iscsi hostdev)
and leak the memory, but that's out of scope of this patch.

Jano

>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 6772c327ed..a33f18c957 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -7632,8 +7632,7 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
>                                authdef->secrettype);
>                 goto cleanup;
>             }
>-            iscsisrc->src->auth = authdef;
>-            authdef = NULL;
>+            VIR_STEAL_PTR(iscsisrc->src->auth, authdef);
>         }
>         cur = cur->next;
>     }

>diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
>index 8319ba9c8c..98f9bc803f 100644
>--- a/src/util/virstoragefile.c
>+++ b/src/util/virstoragefile.c
>@@ -2895,9 +2895,8 @@ virStorageSourceParseRBDColonString(const char *rbdstr,
>             if (VIR_STRDUP(authdef->secrettype,
>                            virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_CEPH)) < 0)
>                 goto error;
>-            src->auth = authdef;
>+            VIR_STEAL_PTR(src->auth, authdef);
>             src->authInherited = true;
>-            authdef = NULL;
>
>             /* Cannot formulate a secretType (eg, usage or uuid) given
>              * what is provided.
>-- 
>2.20.1
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list