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