From: Oliver Kurth Date: Wed, 29 Aug 2018 20:29:45 +0000 (-0700) Subject: Some source code clean up. X-Git-Tag: stable-11.0.0~428 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64848ab7e16492c4bb8544eaff1aa839783e63bf;p=thirdparty%2Fopen-vm-tools.git Some source code clean up. --- diff --git a/open-vm-tools/lib/misc/hostinfoInt.h b/open-vm-tools/lib/misc/hostinfoInt.h index a7d434b42..be352e67f 100644 --- a/open-vm-tools/lib/misc/hostinfoInt.h +++ b/open-vm-tools/lib/misc/hostinfoInt.h @@ -25,7 +25,6 @@ #ifndef _HOSTINFOINT_H_ #define _HOSTINFOINT_H_ - #define MAX_OS_NAME_LEN 128 #define MAX_OS_FULLNAME_LEN 512 #define MAX_STRUCTURED_FIELD_LEN 1024 @@ -39,7 +38,7 @@ typedef struct { char *name; - char value[MAX_STRUCTURED_FIELD_LEN]; + char value[MAX_STRUCTURED_FIELD_LEN]; } StructuredField; /* Must be sorted. Keep in same ordering as structuredFields */ @@ -53,24 +52,23 @@ typedef enum { PRETTY_NAME } StructuredFieldType; -/* Must be sorted. Keep in same ordering as StructuredFieldType. Defined in - * hostinfoPosix.c */ +/* + * Must be sorted. Keep in same ordering as StructuredFieldType. Defined in + * hostinfoPosix.c + */ extern StructuredField structuredFields[]; #define MAX_STRUCTURED_STRING_LEN MAX_STRUCTURED_FIELD_LEN * 10 - extern volatile Bool HostinfoOSNameCacheValid; extern char HostinfoCachedOSName[MAX_OS_NAME_LEN]; extern char HostinfoCachedOSFullName[MAX_OS_FULLNAME_LEN]; extern char HostinfoCachedStructuredString[MAX_STRUCTURED_STRING_LEN]; - /* * Global functions */ extern Bool HostinfoOSData(void); - #endif // ifndef _HOSTINFOINT_H_ diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index f34c2e099..6dce990bf 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -145,7 +145,7 @@ sizeof SYSTEM_BITNESS_64_LINUX)) struct hostinfoOSVersion { - int hostinfoOSVersion[4]; + int hostinfoOSVersion[4]; char *hostinfoOSVersionString; }; @@ -228,14 +228,14 @@ static const DistroInfo distroArray[] = { /* Must be sorted. Keep in same ordering as StructuredFieldType*/ StructuredField structuredFields[] = { - {"BITNESS", ""}, // "32" or "64" - {"BUILD_NUMBER", ""}, // Always present for MacOS. Present for some Linux distros. - {"DISTRO_NAME", ""}, // Defaults to uname -s - {"DISTRO_VERSION", ""}, // Always present for MacOS. Read from distro files for Linux. - {"FAMILY_NAME", ""}, // Defaults to uname -s - {"KERNEL_VERSION", ""}, // Defaults to uname -r - {"PRETTY_NAME", ""}, // Always present for MacOS. Read from distro files for Linux. - {NULL}, + { "bitness", "" }, // "32" or "64" + { "buildNumber", "" }, // Always present for MacOS. Present for some Linux distros. + { "distroName", "" }, // Defaults to uname -s + { "distroVersion", "" }, // Always present for MacOS. Read from distro files for Linux. + { "familyName", "" }, // Defaults to uname -s + { "kernelVersion", "" }, // Defaults to uname -r + { "prettyName", "" }, // Always present for MacOS. Read from distro files for Linux. + { NULL, "" }, // MUST BE LAST }; #if defined __ANDROID__ @@ -559,7 +559,7 @@ HostinfoOSStructuredString(void) sizeof HostinfoCachedStructuredString); for (field = structuredFields; field->name != NULL; field++) { - if (field->value != NULL && *field->value != '\0') { + if (field->value[0] != '\0') { /* Account for escape char and null char */ char escapedString[MAX_STRUCTURED_FIELD_LEN * 2 + 1]; char fieldString[MAX_STRUCTURED_FIELD_LEN]; @@ -598,7 +598,8 @@ HostinfoOSStructuredString(void) } } } - Log("structuredstring = \"%s\"\n", HostinfoCachedStructuredString); + + Log("structured string = \"%s\"\n", HostinfoCachedStructuredString); }