|
|
c480ed |
From 47babc4b1ad1c615df10385bbaafdd30d9359b7a Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <47babc4b1ad1c615df10385bbaafdd30d9359b7a@dist-git>
|
|
|
c480ed |
From: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
|
|
|
c480ed |
Date: Tue, 30 Jul 2019 15:30:46 +0200
|
|
|
c480ed |
Subject: [PATCH] util: command: define cleanup function using
|
|
|
c480ed |
VIR_DEFINE_AUTOPTR_FUNC
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
|
|
|
c480ed |
src/util/viralloc.h, define a new wrapper around an existing
|
|
|
c480ed |
cleanup function which will be called when a variable declared
|
|
|
c480ed |
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
|
|
|
c480ed |
viralloc.h include, since that has moved from the source module into the
|
|
|
c480ed |
header.
|
|
|
c480ed |
|
|
|
c480ed |
When a variable of type virCommandPtr is declared using VIR_AUTOPTR,
|
|
|
c480ed |
the function virCommandFree will be run automatically on it when it
|
|
|
c480ed |
goes out of scope.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
|
|
|
c480ed |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 7e343758920cc954d448b6b14df5707bcd0dbd20)
|
|
|
c480ed |
|
|
|
c480ed |
Prerequisite of: https://bugzilla.redhat.com/show_bug.cgi?id=1721434
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
c480ed |
Message-Id: <40a1fc21abc06c057574a4616eef9981dbfb25dd.1564493409.git.mprivozn@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircommand.c | 1 -
|
|
|
c480ed |
src/util/vircommand.h | 2 ++
|
|
|
c480ed |
2 files changed, 2 insertions(+), 1 deletion(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
|
|
|
c480ed |
index c2b8a1a3c3..d328431373 100644
|
|
|
c480ed |
--- a/src/util/vircommand.c
|
|
|
c480ed |
+++ b/src/util/vircommand.c
|
|
|
c480ed |
@@ -44,7 +44,6 @@
|
|
|
c480ed |
|
|
|
c480ed |
#define __VIR_COMMAND_PRIV_H_ALLOW__
|
|
|
c480ed |
#include "vircommandpriv.h"
|
|
|
c480ed |
-#include "viralloc.h"
|
|
|
c480ed |
#include "virerror.h"
|
|
|
c480ed |
#include "virutil.h"
|
|
|
c480ed |
#include "virlog.h"
|
|
|
c480ed |
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
|
|
|
c480ed |
index 883e212959..90bcc6c89d 100644
|
|
|
c480ed |
--- a/src/util/vircommand.h
|
|
|
c480ed |
+++ b/src/util/vircommand.h
|
|
|
c480ed |
@@ -24,6 +24,7 @@
|
|
|
c480ed |
|
|
|
c480ed |
# include "internal.h"
|
|
|
c480ed |
# include "virbuffer.h"
|
|
|
c480ed |
+# include "viralloc.h"
|
|
|
c480ed |
|
|
|
c480ed |
typedef struct _virCommand virCommand;
|
|
|
c480ed |
typedef virCommand *virCommandPtr;
|
|
|
c480ed |
@@ -218,5 +219,6 @@ int virCommandRunNul(virCommandPtr cmd,
|
|
|
c480ed |
virCommandRunNulFunc func,
|
|
|
c480ed |
void *data);
|
|
|
c480ed |
|
|
|
c480ed |
+VIR_DEFINE_AUTOPTR_FUNC(virCommand, virCommandFree)
|
|
|
c480ed |
|
|
|
c480ed |
#endif /* __VIR_COMMAND_H__ */
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|