From: Oliver Kurth Date: Tue, 18 Dec 2018 21:19:48 +0000 (-0800) Subject: Cleanup -Wno-incompatible-pointer-types-discards-qualifiers X-Git-Tag: stable-11.0.0~278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=601b399538796cc1692c65f30686140c20b0ba33;p=thirdparty%2Fopen-vm-tools.git Cleanup -Wno-incompatible-pointer-types-discards-qualifiers Details Both gcc and clang (on Mac) warn for pointer-incompatible assignments. It appears that gcc's -Wwarn-strings isn't working properly, because it produces no warnings for the following assignment: char *potentialSegV = ".rodata-based string"; However, clang does. This change addresses three problems in bora/lib that produce build failures when -Wincompatible-pointer-types-discards-qualifiers is enabled when using clang (one wonders how many other such potential problems exist?) o bsd_vsnprintf.c The 'cp' pointer is assigned the address of a constant string. Since there are writes through 'cp', the quickest solution is to declare a local, non-const, array variable that holds the string "(null)". o unicodeSimpleTypes.c This change, the easiest of the three, marks the 'char *' field as 'const'. --- diff --git a/open-vm-tools/lib/misc/timeutil.c b/open-vm-tools/lib/misc/timeutil.c index 9d72563aa..856db875e 100644 --- a/open-vm-tools/lib/misc/timeutil.c +++ b/open-vm-tools/lib/misc/timeutil.c @@ -766,7 +766,7 @@ TimeUtil_ProductExpiration(TimeUtil_Expiration *e) // OUT: * determine if a build is set to expire or not. */ #ifdef HARD_EXPIRE - static char *hard_expire = "Expire"; + static char hard_expire[] = "Expire"; (void)hard_expire; ASSERT(e); @@ -785,7 +785,7 @@ TimeUtil_ProductExpiration(TimeUtil_Expiration *e) // OUT: e->daysLeft = TimeUtil_DaysLeft(&e->when); #else - static char *hard_expire = "No Expire"; + static char hard_expire[] = "No Expire"; (void) hard_expire; ASSERT(e); diff --git a/open-vm-tools/lib/unicode/unicodeSimpleTypes.c b/open-vm-tools/lib/unicode/unicodeSimpleTypes.c index 921dbfadd..c721a79ea 100644 --- a/open-vm-tools/lib/unicode/unicodeSimpleTypes.c +++ b/open-vm-tools/lib/unicode/unicodeSimpleTypes.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2007-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2007-2018 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 @@ -63,7 +63,7 @@ static struct xRef { StringEncoding encoding; // ICU encoding enum Bool isSupported; // VMware supported encoding int preferredMime; // Index of preferred MIME name - char *names[MAXCHARSETNAMES]; // Encoding name and aliases + const char *names[MAXCHARSETNAMES]; // Encoding name and aliases } xRef[] = { /* * Source: ECMA registry