]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virCommandFDSet: Remove return value
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Feb 2021 15:18:57 +0000 (16:18 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 5 Mar 2021 14:33:34 +0000 (15:33 +0100)
The function can't fail nowadays. Remove the return value and adjust the
only caller which ensures that @cmd is non-NULL and @fd is positive.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/vircommand.c

index 404d7d2ed6c0085da17ca85335d8c4afb9628290..7f5e053efcd1df7859b23907f66ebe24c6f7feb8 100644 (file)
@@ -216,27 +216,19 @@ virCommandFDIsSet(virCommandPtr cmd,
  * This is practically generalized implementation
  * of FD_SET() as we do not want to be limited
  * by FD_SETSIZE.
- *
- * Returns: 0 on success,
- *          -1 on usage error,
  */
-static int
+static void
 virCommandFDSet(virCommandPtr cmd,
                 int fd,
                 unsigned int flags)
 {
-    if (!cmd || fd < 0)
-        return -1;
-
     if (virCommandFDIsSet(cmd, fd))
-        return 0;
+        return;
 
     ignore_value(VIR_EXPAND_N(cmd->passfd, cmd->npassfd, 1));
 
     cmd->passfd[cmd->npassfd - 1].fd = fd;
     cmd->passfd[cmd->npassfd - 1].flags = flags;
-
-    return 0;
 }
 
 #ifndef WIN32
@@ -1035,8 +1027,6 @@ virCommandNewVAList(const char *binary, va_list list)
 void
 virCommandPassFDIndex(virCommandPtr cmd, int fd, unsigned int flags, size_t *idx)
 {
-    int ret = 0;
-
     if (!cmd) {
         VIR_COMMAND_MAYBE_CLOSE_FD(fd, flags);
         return;
@@ -1050,13 +1040,7 @@ virCommandPassFDIndex(virCommandPtr cmd, int fd, unsigned int flags, size_t *idx
         return;
     }
 
-    if ((ret = virCommandFDSet(cmd, fd, flags)) != 0) {
-        if (!cmd->has_error)
-            cmd->has_error = ret;
-        VIR_DEBUG("cannot preserve %d", fd);
-        VIR_COMMAND_MAYBE_CLOSE_FD(fd, flags);
-        return;
-    }
+    virCommandFDSet(cmd, fd, flags);
 
     if (idx)
         *idx = cmd->npassfd - 1;