]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Code clean up.
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 8 Nov 2021 21:33:58 +0000 (13:33 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 8 Nov 2021 21:33:58 +0000 (13:33 -0800)
 - Fix assignments of pointer to constant data to a non-constant
   pointer type.
 - Remove code that has been commented out.
 - Updated treatment of pointers as a boolean expression to be
   a true boolean expression.
 - Fixed some formatting issues.

open-vm-tools/lib/file/fileInt.h
open-vm-tools/lib/file/fileLockPrimitive.c
open-vm-tools/lib/include/log.h
open-vm-tools/lib/lock/ulInt.h
open-vm-tools/lib/lock/ulStats.c
open-vm-tools/lib/misc/codesetOld.c
open-vm-tools/lib/misc/hostinfoInt.h
open-vm-tools/lib/misc/hostinfoPosix.c

index e8980913c7615d6dbe0e9d8a523c229db0d19aa4..c8f2f627e39e481207c1465a151d2c839d424271 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-2019, 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
@@ -197,7 +197,7 @@ typedef struct lock_values
 {
    char         *machineID;
    char         *executionID;
-   char         *lockType;
+   const char   *lockType;
    char         *locationChecksum;
    char         *memberName;
    unsigned int  lamportNumber;
index adce64209a7ebc1c0d31df614b07e61e0cbe1d6a..374bf80e60feb5b8d3557833d43182ee646e738f 100644 (file)
@@ -72,9 +72,9 @@ static char implicitReadToken;
 
 typedef struct parse_table
 {
-   int    type;
-   char  *name;
-   void  *valuePtr;
+   int         type;
+   const char *name;
+   void       *valuePtr;
 } ParseTable;
 
 /*
index 1df9ac6c35c1eea5c4981fe6629c17660ef98828..163a32381e3b23907ec173c5845ab658cdaaa5ca 100644 (file)
@@ -333,9 +333,9 @@ Log_Trivia(const char *fmt,
 
 #if !defined(VMM)
 typedef struct {
-   int32   legalLevelValue;
-   char   *legalName;
-   char   *levelIdStr;
+   int32       legalLevelValue;
+   const char *legalName;
+   const char *levelIdStr;
 } LogLevelData;
 
 const LogLevelData *
index 2c0447bfbe8b77c80160cb9bdf639bce35bdf848..4b6732ef61893c54bc992494da4e447b498bc6e0 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2009-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2009-2019, 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
@@ -575,7 +575,7 @@ uint32 MXUserStatsMode(void);
 
 typedef struct MXUserHisto MXUserHisto;
 
-MXUserHisto *MXUserHistoSetUp(char *typeName,
+MXUserHisto *MXUserHistoSetUp(const char *typeName,
                               uint64 minValue,
                               uint32 decades);
 
@@ -602,7 +602,7 @@ void MXUserAcquisitionStatsTearDown(MXUserAcquisitionStats *stats);
 
 void
 MXUserBasicStatsSetUp(MXUserBasicStats *stats,
-                      char *typeName);
+                      const char *typeName);
 
 void
 MXUserBasicStatsSample(MXUserBasicStats *stats,
index c301fa522c60aaf0debf44d26314a3e168fcff19..21cb9346212ec4342b4f1b74ec9b2253cb9662db 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2010-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2019, 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
@@ -186,9 +186,9 @@ MXUserHistoIndex(uint64 value)  // IN:
  */
 
 MXUserHisto *
-MXUserHistoSetUp(char *typeName,   // type (name) of histogram
-                 uint64 minValue,  // IN: ns; 1, 10, 100, 1000...
-                 uint32 decades)   // IN: decimal decades to cover from min
+MXUserHistoSetUp(const char *typeName, // type (name) of histogram
+                 uint64 minValue,      // IN: ns; 1, 10, 100, 1000...
+                 uint32 decades)       // IN: decimal decades to cover from min
 {
    MXUserHisto *histo;
 
@@ -448,7 +448,7 @@ MXUserBasicStatsSample(MXUserBasicStats *stats,  // IN/OUT:
 
 void
 MXUserBasicStatsSetUp(MXUserBasicStats *stats,  // IN/OUT:
-                      char *typeName)           // IN:
+                      const char *typeName)     // IN:
 {
    stats->typeName = Util_SafeStrdup(typeName);
    stats->numSamples = 0;
@@ -831,7 +831,7 @@ MXUser_StatisticsControl(double contentionRatioFloor,     // IN:
 
 static INLINE void
 MXUserForceHisto(Atomic_Ptr *histoPtr,  // IN/OUT:
-                 char *typeName,        // IN:
+                 const char *typeName,  // IN:
                  uint64 minValue,       // IN:
                  uint32 decades)        // IN:
 {
index 7d5474c01e02d95f0e224dc0015fa7ebd45c08b8..00d55a2d13cb494510599b3dda75959fc5f16951 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2017,2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2017,2019,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
@@ -731,7 +731,7 @@ CodeSetOld_GetCurrentCodeSet(void)
 
    return ret;
 #elif defined(USE_ICONV)
-   static char *cachedCodeset;
+   static const char *cachedCodeset;
 
    /*
     * Mirror GLib behavior:
@@ -756,16 +756,16 @@ CodeSetOld_GetCurrentCodeSet(void)
     *    the first entry when converting to/from UTF-8.
     */
 
-   if (!cachedCodeset) {
+   if (cachedCodeset == NULL) {
       char *gFilenameEncoding = getenv("G_FILENAME_ENCODING");
 
-      if (gFilenameEncoding && *gFilenameEncoding) {
+      if (gFilenameEncoding != NULL && *gFilenameEncoding != '\0') {
          char *p;
 
          gFilenameEncoding = Util_SafeStrdup(gFilenameEncoding);
          p = strchr(gFilenameEncoding, ',');
 
-         if (p) {
+         if (p != NULL) {
             *p = '\0';
          }
          if (!strcmp(gFilenameEncoding, "@locale")) {
index 4243e42767893071e1fef51df74d661793971754..a3bd79bc6adfa7ab56ef0152c8bd93c3953ec597 100644 (file)
@@ -34,8 +34,8 @@
  */
 
 typedef struct {
-   char  *name;
-   char   value[MAX_DETAILED_FIELD_LEN];
+   const char *name;
+   char        value[MAX_DETAILED_FIELD_LEN];
 } DetailedDataField;
 
 /* Must be sorted. Keep in same ordering as detailedDataFields */
index 56708333f627ffd9a146901d8e88ee99580afaa8..2d873b0933cd4c56fa79f82bae02fa498eab70a4 100644 (file)
@@ -72,7 +72,9 @@
 #if !defined(USING_AUTOCONF) || defined(HAVE_SYS_VFS_H)
 #include <sys/vfs.h>
 #endif
-#if !defined(sun) && !defined __ANDROID__ && (!defined(USING_AUTOCONF) || (defined(HAVE_SYS_IO_H) && defined(HAVE_SYS_SYSINFO_H)))
+#if !defined(sun) && !defined __ANDROID__ && (!defined(USING_AUTOCONF) || \
+                                              (defined(HAVE_SYS_IO_H) && \
+                                               defined(HAVE_SYS_SYSINFO_H)))
 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
 #include <sys/io.h>
 #else
@@ -159,8 +161,8 @@ static Atomic_Ptr hostinfoOSVersion;
 
 #if !defined(__APPLE__) && !defined(VMX86_SERVER) && !defined(USERWORLD)
 typedef struct {
-   char *name;
-   char *scanString;
+   const char *name;
+   const char *scanString;
 } DistroNameScan;
 
 static const DistroNameScan lsbFields[] = {
@@ -180,8 +182,8 @@ static const DistroNameScan osReleaseFields[] = {
 };
 
 typedef struct {
-   char *name;
-   char *filename;
+   const char *name;
+   const char *filename;
 } DistroInfo;
 
 /*
@@ -1842,8 +1844,8 @@ HostinfoDefaultLinux(char *distro,            // OUT/OPT:
                      size_t distroShortSize)  // IN:
 {
    char generic[128];
-   char *distroOut = NULL;
-   char *distroShortOut = NULL;
+   const char *distroOut = NULL;
+   const char *distroShortOut = NULL;
    int majorVersion = Hostinfo_OSVersion(0);
    int minorVersion = Hostinfo_OSVersion(1);
 
@@ -3337,8 +3339,8 @@ Hostinfo_Daemonize(const char *path,             // IN: NUL-terminated UTF-8
  */
 
 static char *
-HostinfoGetCpuInfo(int nCpu,    // IN:
-                   char *name)  // IN:
+HostinfoGetCpuInfo(int nCpu,         // IN:
+                   const char *name) // IN:
 {
    FILE *f;
    char *line;
@@ -3921,7 +3923,7 @@ NOT_IMPLEMENTED();
 
 static Bool
 HostinfoFindEntry(char *buffer,         // IN: Buffer
-                  char *string,         // IN: String sought
+                  const char *string,   // IN: String sought
                   unsigned int *value)  // OUT: Value
 {
    char *p = strstr(buffer, string);
@@ -3969,8 +3971,8 @@ HostinfoFindEntry(char *buffer,         // IN: Buffer
  */
 
 static Bool
-HostinfoGetMemInfo(char *name,           // IN:
-                   unsigned int *value)  // OUT:
+HostinfoGetMemInfo(const char *name,    // IN:
+                   unsigned int *value) // OUT:
 {
    size_t len;
    char   buffer[4096];