]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Clean up lib/file/file.c
authorOliver Kurth <okurth@vmware.com>
Wed, 10 Jun 2020 19:05:45 +0000 (12:05 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 10 Jun 2020 19:05:45 +0000 (12:05 -0700)
Consistency with the remainder of lib/file.

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

index 30d4919599c377f8a6b6357105899d64bdd80e8f..c8cfe0211c112bb61c0e434af996ad688742b0aa 100644 (file)
@@ -1299,7 +1299,7 @@ File_Move(const char *oldFile,  // IN:
       }
    }
 
-   if (asRename) {
+   if (asRename != NULL) {
       *asRename = duringRename;
    }
 
@@ -1330,7 +1330,9 @@ File_Move(const char *oldFile,  // IN:
  *
  * Side effects:
  *    - Deletes the originating directory
- *    - In the event of a failed copy we'll leave the new directory in a state
+ *    - In the event of a failed copy we'll leave the new directory in an
+ *      undefined state. Calling File_DeleteDirectoryContent would be a
+ *      good idea.
  *
  *-----------------------------------------------------------------------------
  */
@@ -1347,7 +1349,7 @@ File_MoveTree(const char *srcName,    // IN:
    ASSERT(srcName != NULL);
    ASSERT(dstName != NULL);
 
-   if (asMove) {
+   if (asMove != NULL) {
       *asMove = FALSE;
    }
 
@@ -1360,7 +1362,7 @@ File_MoveTree(const char *srcName,    // IN:
    }
 
    if (File_Rename(srcName, dstName) == 0) {
-      if (asMove) {
+      if (asMove != NULL) {
          *asMove = TRUE;
       }
 
@@ -1403,15 +1405,14 @@ File_MoveTree(const char *srcName,    // IN:
        */
       if (createdDir) {
          /*
-          * Check for free space on destination filesystem.
-          * We only check for free space if the destination directory
-          * did not exist. In this case, we will not be overwriting any existing
-          * paths, so we need as much space as srcName.
+          * Check for free space on destination filesystem. We only check for
+          * free space if the destination directory did not exist. In this
+          * case, we will not be overwriting any existing paths, so we need as
+          * much space as srcName.
           */
-         int64 srcSize;
-         int64 freeSpace;
-         srcSize = File_GetSizeEx(srcName);
-         freeSpace = File_GetFreeSpace(dstName, TRUE);
+         int64 srcSize = File_GetSizeEx(srcName);
+         int64 freeSpace = File_GetFreeSpace(dstName, TRUE);
+
          if (freeSpace < srcSize) {
             char *spaceStr = Msg_FormatSizeInBytes(srcSize);
             Msg_Append(MSGID(File.MoveTree.dst.insufficientSpace)
@@ -1476,9 +1477,7 @@ File_MoveTree(const char *srcName,    // IN:
 char *
 File_GetModTimeString(const char *pathName)  // IN:
 {
-   int64 modTime;
-
-   modTime = File_GetModTime(pathName);
+   int64 modTime = File_GetModTime(pathName);
 
    return (modTime == -1) ? NULL : TimeUtil_GetTimeFormat(modTime, TRUE, TRUE);
 }
@@ -1655,7 +1654,7 @@ FileFirstSlashIndex(const char *pathName,     // IN:
    UnicodeIndex firstBS;
 #endif
 
-   ASSERT(pathName);
+   ASSERT(pathName != NULL);
 
    firstFS = Unicode_FindSubstrInRange(pathName, startIndex, -1,
                                        "/", 0, 1);
@@ -1836,11 +1835,10 @@ Bool
 File_CreateDirectoryHierarchy(const char *pathName,   // IN:
                               char **topmostCreated)  // OUT/OPT:
 {
-   return File_CreateDirectoryHierarchyEx(pathName,
-                                          0777,
-                                          topmostCreated);
+   return File_CreateDirectoryHierarchyEx(pathName, 0777, topmostCreated);
 }
 
+
 /*
  *----------------------------------------------------------------------
  *
@@ -2107,7 +2105,7 @@ File_FindFileInSearchPath(const char *fileIn,      // IN:
    sp = Util_SafeStrdup(searchPath);
    tok = strtok_r(sp, FILE_SEARCHPATHTOKEN, &saveptr);
 
-   while (tok) {
+   while (tok != NULL) {
       if (File_IsFullPath(tok)) {
          /* Fully Qualified Path. Use it. */
          cur = Str_SafeAsprintf(NULL, "%s%s%s", tok, DIRSEPS, file);
@@ -2137,7 +2135,7 @@ File_FindFileInSearchPath(const char *fileIn,      // IN:
    }
 
 done:
-   if (cur) {
+   if (cur != NULL) {
       found = TRUE;
 
       if (result) {
@@ -2715,11 +2713,12 @@ File_IsSubPathOf(const char *base, // IN: the base path to test against.
    char *fullPath = File_FullPath(path);
    Bool isSubPath = TRUE;
 
-   ASSERT(fullBase);
-   ASSERT(fullPath);
-   if (   fullPath == NULL
-       || fullBase == NULL
-       || strncmp(fullPath, fullBase, strlen(fullBase)) != 0) {
+   ASSERT(fullBase != NULL);
+   ASSERT(fullPath != NULL);
+
+   if (fullPath == NULL ||
+       fullBase == NULL ||
+       strncmp(fullPath, fullBase, strlen(fullBase)) != 0) {
       isSubPath = FALSE;
    }