diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 2efc0dd72c7d6857d786c164aa7eb57f8d7924fb..c2e4c3df5180065904b2a3ff3d495038f116b493 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -917,7 +917,7 @@ virSystemdActivationNew(virSystemdActivationMap *map, return act; error: - virSystemdActivationFree(&act); + virSystemdActivationFree(act); return NULL; } @@ -1046,12 +1046,12 @@ virSystemdActivationClaimFDs(virSystemdActivationPtr act, * associated with the activation object */ void -virSystemdActivationFree(virSystemdActivationPtr *act) +virSystemdActivationFree(virSystemdActivationPtr act) { - if (!*act) + if (!act) return; - virHashFree((*act)->fds); + virHashFree(act->fds); - VIR_FREE(*act); + VIR_FREE(act); } diff --git a/src/util/virsystemd.h b/src/util/virsystemd.h index 5f1a4413fe57cbc5982787055cb2bc5442438ba1..2c0a0d8dc084b0ad85877ef24808c12cb71c7b68 100644 --- a/src/util/virsystemd.h +++ b/src/util/virsystemd.h @@ -22,6 +22,7 @@ #pragma once #include "internal.h" +#include "virautoclean.h" typedef struct _virSystemdActivation virSystemdActivation; typedef virSystemdActivation *virSystemdActivationPtr; @@ -81,6 +82,6 @@ void virSystemdActivationClaimFDs(virSystemdActivationPtr act, int **fds, size_t *nfds); -void virSystemdActivationFree(virSystemdActivationPtr *act); +void virSystemdActivationFree(virSystemdActivationPtr act); -#define virSystemdActivationAutoPtrFree virSystemdActivationFree +VIR_DEFINE_AUTOPTR_FUNC(virSystemdActivation, virSystemdActivationFree); diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index 3add1ab56fe4c0fa440f82cdf220dd5be7feed46..d33a7c192ffec1035fe34e48e6bc898043c29ab3 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -650,7 +650,7 @@ testActivationEmpty(const void *opaque ATTRIBUTE_UNUSED) if (act != NULL) { fprintf(stderr, "Unexpectedly got activation object"); - virSystemdActivationFree(&act); + virSystemdActivationFree(act); return -1; }