]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Common source file change not directly applicable to open-vm-tools.
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 5 Apr 2021 16:01:41 +0000 (09:01 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 5 Apr 2021 16:01:41 +0000 (09:01 -0700)
lib/file/file.c:

Revised File_UnlinkRetry() and File_UnlinkNoFollow() to return 0 for
success and an errno for failure.  Previously, a failure was indicated
by a -1 and the caller had to retrieve the errno.

open-vm-tools/lib/file/file.c

index 46933c594c006b96771fe1642ffc78946efcd0f5..7b386685d0a62ee5dd74b2d543502dd5737d18d1 100644 (file)
@@ -285,7 +285,8 @@ File_Unlink(const char *pathName)  // IN:
  *      Errno/GetLastError is available upon failure.
  *
  * Results:
- *      Return 0 if the unlink is successful. Otherwise, returns -1.
+ *        0  success
+ *      > 0  failure (errno)
  *
  * Side effects:
  *      The file is removed.
@@ -296,7 +297,9 @@ File_Unlink(const char *pathName)  // IN:
 int
 File_UnlinkNoFollow(const char *pathName)  // IN:
 {
-   return (FileDeletion(pathName, FALSE) == 0) ? 0 : -1;
+   errno = FileDeletion(pathName, FALSE);
+
+   return errno;
 }
 
 
@@ -308,7 +311,8 @@ File_UnlinkNoFollow(const char *pathName)  // IN:
  *      Unlink the file, retrying on EBUSY on ESX, up to given timeout.
  *
  * Results:
- *      Return 0 if the unlink is successful. Otherwise, return -1.
+ *        0  success
+ *      > 0  failure (errno)
  *
  * Side effects:
  *      The file is removed.
@@ -320,16 +324,14 @@ int
 File_UnlinkRetry(const char *pathName,       // IN:
                  uint32 maxWaitTimeMilliSec) // IN:
 {
-   int ret;
-
    if (vmx86_server) {
       uint32 const unlinkWait = 300;
       uint32 waitMilliSec = 0;
 
       do {
-         ret = FileDeletion(pathName, TRUE);
+         errno = FileDeletion(pathName, TRUE);
 
-         if (ret != EBUSY || waitMilliSec >= maxWaitTimeMilliSec) {
+         if (errno != EBUSY || waitMilliSec >= maxWaitTimeMilliSec) {
             break;
          }
 
@@ -339,10 +341,10 @@ File_UnlinkRetry(const char *pathName,       // IN:
          waitMilliSec += unlinkWait;
       } while (TRUE);
    } else {
-      ret = FileDeletion(pathName, TRUE);
+      errno = FileDeletion(pathName, TRUE);
    }
 
-   return ret == 0 ? 0 : -1;
+   return errno;
 }