From: John Wolfe Date: Mon, 8 Nov 2021 21:33:58 +0000 (-0800) Subject: Code clean up. X-Git-Tag: stable-12.0.0~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53a3387f9bb7f15fd504d6a44c4d8608c1b6ef56;p=thirdparty%2Fopen-vm-tools.git Code clean up. - 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. --- diff --git a/open-vm-tools/lib/file/fileInt.h b/open-vm-tools/lib/file/fileInt.h index e8980913c..c8f2f627e 100644 --- a/open-vm-tools/lib/file/fileInt.h +++ b/open-vm-tools/lib/file/fileInt.h @@ -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; diff --git a/open-vm-tools/lib/file/fileLockPrimitive.c b/open-vm-tools/lib/file/fileLockPrimitive.c index adce64209..374bf80e6 100644 --- a/open-vm-tools/lib/file/fileLockPrimitive.c +++ b/open-vm-tools/lib/file/fileLockPrimitive.c @@ -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; /* diff --git a/open-vm-tools/lib/include/log.h b/open-vm-tools/lib/include/log.h index 1df9ac6c3..163a32381 100644 --- a/open-vm-tools/lib/include/log.h +++ b/open-vm-tools/lib/include/log.h @@ -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 * diff --git a/open-vm-tools/lib/lock/ulInt.h b/open-vm-tools/lib/lock/ulInt.h index 2c0447bfb..4b6732ef6 100644 --- a/open-vm-tools/lib/lock/ulInt.h +++ b/open-vm-tools/lib/lock/ulInt.h @@ -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, diff --git a/open-vm-tools/lib/lock/ulStats.c b/open-vm-tools/lib/lock/ulStats.c index c301fa522..21cb93462 100644 --- a/open-vm-tools/lib/lock/ulStats.c +++ b/open-vm-tools/lib/lock/ulStats.c @@ -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: { diff --git a/open-vm-tools/lib/misc/codesetOld.c b/open-vm-tools/lib/misc/codesetOld.c index 7d5474c01..00d55a2d1 100644 --- a/open-vm-tools/lib/misc/codesetOld.c +++ b/open-vm-tools/lib/misc/codesetOld.c @@ -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")) { diff --git a/open-vm-tools/lib/misc/hostinfoInt.h b/open-vm-tools/lib/misc/hostinfoInt.h index 4243e4276..a3bd79bc6 100644 --- a/open-vm-tools/lib/misc/hostinfoInt.h +++ b/open-vm-tools/lib/misc/hostinfoInt.h @@ -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 */ diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index 56708333f..2d873b093 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -72,7 +72,9 @@ #if !defined(USING_AUTOCONF) || defined(HAVE_SYS_VFS_H) #include #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 #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];