[libvirt] [PATCH 2/5] util: object: Reset pointer when unrefing object in virObjectAutoUnref

Peter Krempa posted 5 patches 6 years, 11 months ago
[libvirt] [PATCH 2/5] util: object: Reset pointer when unrefing object in virObjectAutoUnref
Posted by Peter Krempa 6 years, 11 months ago
The helper function is used by the VIR_AUTOUNREF macro. Prior art is to
clear the pointer even if the variable goes out of scope.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/util/virobject.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/util/virobject.c b/src/util/virobject.c
index a4cbd08077..f08c18ce44 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -372,6 +372,7 @@ virObjectAutoUnref(void *objptr)
 {
     virObjectPtr *obj = objptr;
     virObjectUnref(*obj);
+    *obj = NULL;
 }


-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/5] util: object: Reset pointer when unrefing object in virObjectAutoUnref
Posted by Ján Tomko 6 years, 11 months ago
The commit summary mentions object thrice.
    util: reset pointer in virObjectAutoUnref
is less wasteful. Otherwise at least s/unrefing/unreffing/


On Tue, Feb 26, 2019 at 06:08:09PM +0100, Peter Krempa wrote:
>The helper function is used by the VIR_AUTOUNREF macro. Prior art is to
>clear the pointer even if the variable goes out of scope.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/util/virobject.c | 1 +
> 1 file changed, 1 insertion(+)
>

This saves developer time that would otherwise be spent on bikeshedding.
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