]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/file/file.c: File_Unlink()
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)
Revised File_Unlink() 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
open-vm-tools/services/plugins/dndcp/dnd/dndCommon.c

index 7b386685d0a62ee5dd74b2d543502dd5737d18d1..90677e833ba92774737b4f3b604911f6339e161c 100644 (file)
@@ -258,7 +258,8 @@ File_GetFilePermissions(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.
@@ -269,7 +270,9 @@ File_GetFilePermissions(const char *pathName,  // IN:
 int
 File_Unlink(const char *pathName)  // IN:
 {
-   return (FileDeletion(pathName, TRUE) == 0) ? 0 : -1;
+   errno = FileDeletion(pathName, TRUE);
+
+   return errno;
 }
 
 
index c42d05b7ef4f29df61ab9d20e203802229e2c5a1..74592f2ef75af5f88194073698d1f19b241a8099 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2005-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2005-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -270,7 +270,7 @@ DnD_DeleteStagingFiles(const char *stagingDir,  // IN:
                ret = FALSE;
             }
          } else {
-            if (File_Unlink(curPath) == -1) {
+            if (File_Unlink(curPath) != 0) {
                ret = FALSE;
             }
          }