On a Friday in 2020, Tim Wiederhake wrote:
Signed-off-by: Tim Wiederhake <twied...@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

Attachment: signature.asc
Description: PGP signature

Reply via email to