[libvirt PATCH 1/5] docs: use g_auto in virCommand example

Ján Tomko jtomko at redhat.com
Mon Dec 13 18:58:46 UTC 2021


Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 docs/internals/command.html.in | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/docs/internals/command.html.in b/docs/internals/command.html.in
index 585ba53a93..d9f53933c6 100644
--- a/docs/internals/command.html.in
+++ b/docs/internals/command.html.in
@@ -564,14 +564,12 @@ int runhook(const char *drvstr, const char *id,
             const char *opstr, const char *subopstr,
             const char *extra)
 {
-  int ret;
-  char *path;
-  virCommand *cmd;
+  g_autofree char *path = NULL;
+  g_autoptr(virCommand) cmd = NULL;
 
   virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr);
 
   cmd = virCommandNew(path);
-  VIR_FREE(path);
 
   virCommandAddEnvPassCommon(cmd);
 
@@ -579,11 +577,7 @@ int runhook(const char *drvstr, const char *id,
 
   virCommandSetInputBuffer(cmd, input);
 
-  ret = virCommandRun(cmd, NULL);
-
-  virCommandFree(cmd);
-
-  return ret;
+  return virCommandRun(cmd, NULL);
 }
 </pre>
 
-- 
2.31.1




More information about the libvir-list mailing list