]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Address two Coverity-reported issues in hostinfoPosix.c.
authorOliver Kurth <okurth@vmware.com>
Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)
committerOliver Kurth <okurth@vmware.com>
Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)
Rework some code with the intent of making it more straightfoward,
which also eliminates a false positive.

Check the return value from PosixUnlink and log a warning on error.

open-vm-tools/lib/misc/hostinfoPosix.c

index 3baee94f43f1fcc92d72d5773a75b17ca7602f94..941bc053acd0b2b816c5d8ac92485dc4cef464c1 100644 (file)
@@ -1153,10 +1153,7 @@ out:
    if (success) {
       result[nArgs - 1] = DynBuf_Detach(&b);
    } else {
-      if (nArgs != 0) {
-         Util_FreeStringList(result, nArgs);
-      }
-
+      Util_FreeStringList(result, nArgs);
       result = NULL;
    }
 
@@ -2910,7 +2907,10 @@ Hostinfo_Daemonize(const char *path,             // IN: NUL-terminated UTF-8
           * with another process attempting to daemonize and unlinking the
           * file it created instead.
           */
-         Posix_Unlink(pidPath);
+         if (Posix_Unlink(pidPath) != 0) {
+            Warning("%s: Unable to unlink %s: %u\n",
+                    __FUNCTION__, pidPath, errno);
+         }
       }
 
       errno = err;