]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
docs: use g_auto in virCommand example
authorJán Tomko <jtomko@redhat.com>
Mon, 13 Dec 2021 18:47:25 +0000 (19:47 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 14 Dec 2021 15:41:36 +0000 (16:41 +0100)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/internals/command.html.in

index 585ba53a93742a0dfce36ae0dfdf6fc90ae69518..d9f53933c63f7918c1d26e01ba40f51d24c73ffc 100644 (file)
@@ -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(&amp;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>