]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircommand: Initialize dryRunStatus to portable EXIT_SUCCESS instead of 0
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 18 Jul 2024 07:37:55 +0000 (09:37 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Jul 2024 14:47:55 +0000 (16:47 +0200)
If dry run of a command was requested (virCommandSetDryRun())
then a specified callback is called instead of running actual
command. This is meant to be used in tests. To mimic running the
command as closely as possible the callback can also set exit
status of the command it's implementing. To save some lines
though, the exit status is initialized to 0 so that callback has
to set it only on failures. Now, 0 is not exactly portable value
- that's why stdlib.h has EXIT_SUCCESS (and EXIT_FAILURE) values.
Initialize the exit status (held in dryRunStatus) to EXIT_SUCCESS
then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/util/vircommand.c

index 07bee9b12e5fb4ea7bf8c47672904004b46e52e0..a03fcc37ae736a37a38ac2e43ce7d9b055c38c40 100644 (file)
@@ -2630,7 +2630,7 @@ virCommandRunAsync(virCommand *cmd, pid_t *pid)
 
     if (dryRunBuffer || dryRunCallback) {
         g_autofree char *cmdstr = NULL;
-        dryRunStatus = 0;
+        dryRunStatus = EXIT_SUCCESS;
 
         if (!(cmdstr = virCommandToStringFull(cmd, dryRunBufferArgLinebreaks,
                                               dryRunBufferCommandStripPath)))