[PATCH 3/7] cputest: Avoid use of temporary variable in DO_TEST macro

Peter Krempa posted 7 patches 5 years, 8 months ago
[PATCH 3/7] cputest: Avoid use of temporary variable in DO_TEST macro
Posted by Peter Krempa 5 years, 8 months ago
Use g_free directly to free the returned pointer from
virTestLogContentAndReset rather than store it in a temp variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/cputest.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tests/cputest.c b/tests/cputest.c
index b66ea7850e..0cf6870574 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -997,10 +997,8 @@ mymain(void)
             flags, result \
         }; \
         char *testLabel; \
-        char *tmp; \
  \
-        tmp = virTestLogContentAndReset(); \
-        VIR_FREE(tmp); \
+        g_free(virTestLogContentAndReset());\
  \
         testLabel = g_strdup_printf("%s(%s): %s", #api, \
                                     virArchToString(arch), name); \
-- 
2.26.2

Re: [PATCH 3/7] cputest: Avoid use of temporary variable in DO_TEST macro
Posted by Ján Tomko 5 years, 8 months ago
On a Thursday in 2020, Peter Krempa wrote:
>Use g_free directly to free the returned pointer from
>virTestLogContentAndReset rather than store it in a temp variable.
>

Needed back when VIR_FREE was mandated in:
8fe454ce90899945b1d16674668a0208657b6e61

>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> tests/cputest.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>

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

Jano