[libvirt PATCH 04/21] util: Use glib memory functions in virErrorCopyNew
Ján Tomko
jtomko at redhat.com
Fri Sep 11 15:37:52 UTC 2020
On a Friday in 2020, Tim Wiederhake wrote:
>Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
>---
> src/util/virerror.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
>diff --git a/src/util/virerror.c b/src/util/virerror.c
>index 507a29f50f..4ba99defbb 100644
>--- a/src/util/virerror.c
>+++ b/src/util/virerror.c
>@@ -223,15 +223,14 @@ virCopyError(virErrorPtr from,
> virErrorPtr
> virErrorCopyNew(virErrorPtr err)
> {
>- virErrorPtr ret;
>+ g_autoptr(virError) ret = NULL;
>
Using g_auto is not mandatory, sometimes it adds more
clutter to the code than it removes.
>- if (VIR_ALLOC_QUIET(ret) < 0)
>- return NULL;
>+ ret = g_new0(virError, 1);
>
> if (virCopyError(err, ret) < 0)
>- VIR_FREE(ret);
As of commit 18f377178a3bee6df4c63283ff61b75c21bc0d52 virCopyError
always returns 0, so this condition is pointless.
virCopyError(err, ret);
should be enough and it would remove the need for g_auto.
Jano
>+ return NULL;
>
>- return ret;
>+ return g_steal_pointer(&ret);
> }
>
>
>--
>2.26.2
>
-------------- 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/9c74de6c/attachment-0001.sig>
More information about the libvir-list
mailing list