]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/file: some cleanup
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:19 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:19 +0000 (11:23 -0700)
Line things up; style made common

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

index 710fb7c8830fcc78d8223d03091546571ecbb48a..a55d4efd28e46f0a24c7f19a63694e40bed60bee 100644 (file)
@@ -69,7 +69,7 @@
  */
 
 const char *
-FileIO_ErrorEnglish(FileIOResult status) // IN
+FileIO_ErrorEnglish(FileIOResult status)  // IN:
 {
    return Msg_StripMSGID(FileIO_MsgError(status));
 }
@@ -92,7 +92,7 @@ FileIO_ErrorEnglish(FileIOResult status) // IN
  */
 
 const char *
-FileIO_MsgError(FileIOResult status) // IN
+FileIO_MsgError(FileIOResult status)  // IN:
 {
    const char *result = NULL;
 
@@ -201,8 +201,8 @@ void
 FileIO_Init(FileIODescriptor *fd,  // IN/OUT:
             const char *pathName)  // IN:
 {
-   ASSERT(fd);
-   ASSERT(pathName);
+   ASSERT(fd != NULL);
+   ASSERT(pathName != NULL);
 
    fd->fileName = Unicode_Duplicate(pathName);
 }
@@ -228,7 +228,7 @@ FileIO_Init(FileIODescriptor *fd,  // IN/OUT:
 void
 FileIO_Cleanup(FileIODescriptor *fd)  // IN/OUT:
 {
-   ASSERT(fd);
+   ASSERT(fd != NULL);
 
    if (fd->fileName) {
       free(fd->fileName);
@@ -319,7 +319,7 @@ FileIO_Lock(FileIODescriptor *file,  // IN/OUT:
     * Lock the file if necessary.
     */
 
-   ASSERT(file);
+   ASSERT(file != NULL);
    ASSERT(file->lockToken == NULL);
 
    FileIOResolveLockBits(&access);
@@ -392,7 +392,7 @@ FileIO_Unlock(FileIODescriptor *file)  // IN/OUT:
 {
    FileIOResult ret = FILEIO_SUCCESS;
 
-   ASSERT(file);
+   ASSERT(file != NULL);
 
 #if !defined(__FreeBSD__) && !defined(sun)
    if (file->lockToken != NULL) {
@@ -488,7 +488,7 @@ FileIO_GetSizeByPath(const char *pathName)  // IN:
 const char *
 FileIO_Filename(FileIODescriptor *fd)  // IN:
 {
-   ASSERT(fd);
+   ASSERT(fd != NULL);
 
    return fd->fileName;
 }
@@ -518,7 +518,7 @@ FileIO_CloseAndUnlink(FileIODescriptor *fd)  // IN:
    char *path;
    FileIOResult ret;
 
-   ASSERT(fd);
+   ASSERT(fd != NULL);
    ASSERT(FileIO_IsValid(fd));
 
    path = Unicode_Duplicate(fd->fileName);
@@ -565,7 +565,7 @@ FileIO_Pread(FileIODescriptor *fd,  // IN: File descriptor
 {
    struct iovec iov;
 
-   ASSERT(fd);
+   ASSERT(fd != NULL);
 
    iov.iov_base = buf;
    iov.iov_len = len;
@@ -601,7 +601,7 @@ FileIO_Pwrite(FileIODescriptor *fd,  // IN: File descriptor
 {
    struct iovec iov;
 
-   ASSERT(fd);
+   ASSERT(fd != NULL);
 
    /* The cast is safe because FileIO_Pwritev() will not write to '*buf'. */
    iov.iov_base = (void *)buf;
@@ -664,7 +664,7 @@ FileIO_AtomicTempPath(const char *path)  // IN:
    char *retPath;
 
    srcPath = File_FullPath(path);
-   if (!srcPath) {
+   if (srcPath == NULL) {
       Log("%s: File_FullPath of '%s' failed.\n", __FUNCTION__, path);
       return NULL;
    }
@@ -709,7 +709,7 @@ FileIO_AtomicTempFile(FileIODescriptor *fileFD,  // IN:
    ASSERT(tempFD && !FileIO_IsValid(tempFD));
 
    tempPath = FileIO_AtomicTempPath(FileIO_Filename(fileFD));
-   if (!tempPath) {
+   if (tempPath == NULL) {
       status = FILEIO_ERROR;
       goto bail;
    }
@@ -847,7 +847,7 @@ FileIO_AtomicUpdate(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
       char *dstFileName = NULL;
 
       currPath = File_FullPath(FileIO_Filename(currFD));
-      if (!currPath) {
+      if (currPath == NULL) {
          savedErrno = errno;
          Log("%s: File_FullPath of '%s' failed.\n", __FUNCTION__,
              FileIO_Filename(currFD));
@@ -855,7 +855,7 @@ FileIO_AtomicUpdate(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
       }
 
       newPath = File_FullPath(FileIO_Filename(newFD));
-      if (!newPath) {
+      if (newPath == NULL) {
          savedErrno = errno;
          Log("%s: File_FullPath of '%s' failed.\n", __FUNCTION__,
              FileIO_Filename(newFD));
@@ -865,9 +865,9 @@ FileIO_AtomicUpdate(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
       File_GetPathName(newPath, &dirName, &fileName);
       File_GetPathName(currPath, &dstDirName, &dstFileName);
 
-      ASSERT(dirName);
+      ASSERT(dirName != NULL);
       ASSERT(fileName && *fileName);
-      ASSERT(dstDirName);
+      ASSERT(dstDirName != NULL);
       ASSERT(dstFileName && *dstFileName);
       ASSERT(File_IsSameFile(dirName, dstDirName));
 
index 4207e36211981b471f69b8605793f2743a046d14..24f2a4a39edf878a74a21037b919eaf7d04d652c 100644 (file)
@@ -525,7 +525,7 @@ File_StripFwdSlashes(const char *pathName)  // IN:
    char *prev;
    char *result;
 
-   ASSERT(pathName);
+   ASSERT(pathName != NULL);
 
    path = Unicode_GetAllocBytes(pathName, STRING_ENCODING_UTF8);
    ASSERT(path != NULL);
@@ -923,7 +923,7 @@ Bool
 File_SetFilePermissions(const char *pathName,  // IN:
                         int perms)             // IN: permissions
 {
-   ASSERT(pathName);
+   ASSERT(pathName != NULL);
 
    if (Posix_Chmod(pathName, perms) == -1) {
       /* The error is not critical, just log it. */
@@ -970,7 +970,7 @@ FilePosixGetParent(char **canPath)  // IN/OUT: Canonical file path
    char *pathName;
    char *baseName;
 
-   ASSERT(canPath);
+   ASSERT(canPath != NULL);
    ASSERT(File_IsFullPath(*canPath));
 
    if (Unicode_Compare(*canPath, DIRSEPS) == 0) {
@@ -1291,7 +1291,7 @@ File_GetVMFSVersion(const char *pathName,  // IN: File name to test
    int ret = -1;
    FS_PartitionListResult *fsAttrs = NULL;
 
-   if (!versionNum) {
+   if (versionNum == NULL) {
       errno = EINVAL;
       goto exit;
    }
@@ -1337,7 +1337,7 @@ File_GetVMFSBlockSize(const char *pathName,  // IN: File name to test
    int ret = -1;
    FS_PartitionListResult *fsAttrs = NULL;
 
-   if (!blockSize) {
+   if (blockSize == NULL) {
       errno = EINVAL;
       goto exit;
    }
@@ -1555,11 +1555,12 @@ File_SupportsOptimisticLock(const char *pathName)  // IN:
     * File_GetVMFSFSType works much faster on directories, so get the
     * directory.
     */
-   if (!File_IsFullPath(pathName)) {
+
+   if (File_IsFullPath(pathName)) {
+      fullPath = pathName;
+   } else {
       tempPath = File_FullPath(pathName);
       fullPath = tempPath;
-   } else {
-      fullPath = pathName;
    }
    File_GetPathName(fullPath, &dir, NULL);
    res = File_GetVMFSFSType(dir, -1, &fsTypeNum);
@@ -1755,8 +1756,8 @@ FilePosixLookupMountPoint(char const *canPath,  // IN: Canonical file path
    size_t used;
    char *ret = NULL;
 
-   ASSERT(canPath);
-   ASSERT(bind);
+   ASSERT(canPath != NULL);
+   ASSERT(bind != NULL);
 
    size = 4 * FILE_MAXPATH;  // Should suffice for most locales
 
@@ -2038,7 +2039,7 @@ FilePosixNearestExistingAncestor(char const *path)  // IN: File path
       }
 
       ptr = strrchr(result, DIRSEPC);
-      if (!ptr) {
+      if (ptr == NULL) {
          ptr = result;
       }
       *ptr = '\0';
@@ -2088,8 +2089,8 @@ File_IsSameFile(const char *path1,  // IN:
    struct statfs stfs2;
 #endif
 
-   ASSERT(path1);
-   ASSERT(path2);
+   ASSERT(path1 != NULL);
+   ASSERT(path2 != NULL);
 
    /*
     * First take care of the easy checks.  If the paths are identical, or if
@@ -2290,8 +2291,8 @@ FilePosixGetMaxOrSupportsFileSize(FileIODescriptor *fd,  // IN:
    uint64 value = 0;
    uint64 mask;
 
-   ASSERT(fd);
-   ASSERT(fileSize);
+   ASSERT(fd != NULL);
+   ASSERT(fileSize != NULL);
 
    if (!getMaxFileSize) {
       return FileIO_SupportsFileSize(fd, *fileSize);
@@ -2347,7 +2348,7 @@ FilePosixCreateTestGetMaxOrSupportsFileSize(const char *dirName, // IN: test dir
    char *path;
    FileIODescriptor fd;
 
-   ASSERT(fileSize);
+   ASSERT(fileSize != NULL);
 
    temp = Unicode_Append(dirName, "/.vmBigFileTest");
    posixFD = File_MakeSafeTemp(temp, &path);
@@ -2404,7 +2405,7 @@ FileVMKGetMaxFileSize(const char *pathName,  // IN:
 
    char *dirPath = NULL;
 
-   ASSERT(maxFileSize);
+   ASSERT(maxFileSize != NULL);
 
    fullPath = File_FullPath(pathName);
    if (fullPath == NULL) {
@@ -2608,7 +2609,8 @@ FileGetMaxOrSupportsFileSize(const char *pathName,  // IN:
    char *folderPath;
    Bool retval = FALSE;
 
-   ASSERT(fileSize);
+   ASSERT(pathName != NULL);
+   ASSERT(fileSize != NULL);
 
    /*
     * We acquire the full path name for testing in
@@ -2694,7 +2696,7 @@ File_GetMaxFileSize(const char *pathName,  // IN:
 {
    Bool result;
 
-   if (!maxFileSize) {
+   if (maxFileSize == NULL) {
       Log(LGPFX" %s: maxFileSize passed as NULL.\n", __func__);
 
       return FALSE;
@@ -3031,7 +3033,7 @@ File_WalkDirectoryNext(WalkDirContext context,  // IN:
                        char **path)             // OUT:
 {
    ASSERT(context);
-   ASSERT(path);
+   ASSERT(path != NULL);
 
    errno = 0;  // Any errors showed up at "start time".