From: John Wolfe Date: Mon, 5 Apr 2021 16:01:41 +0000 (-0700) Subject: Common source file change not directly applicable to open-vm-tools. X-Git-Tag: stable-11.3.0~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=996626d977b3e5186d4664491b740a8afc6f45cd;p=thirdparty%2Fopen-vm-tools.git Common source file change not directly applicable to open-vm-tools. 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. --- diff --git a/open-vm-tools/lib/file/file.c b/open-vm-tools/lib/file/file.c index 46933c594..7b386685d 100644 --- a/open-vm-tools/lib/file/file.c +++ b/open-vm-tools/lib/file/file.c @@ -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; }