]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Cleanup -Wno-incompatible-pointer-types-discards-qualifiers
authorOliver Kurth <okurth@vmware.com>
Tue, 18 Dec 2018 21:19:48 +0000 (13:19 -0800)
committerOliver Kurth <okurth@vmware.com>
Tue, 18 Dec 2018 21:19:48 +0000 (13:19 -0800)
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'.

open-vm-tools/lib/misc/timeutil.c
open-vm-tools/lib/unicode/unicodeSimpleTypes.c

index 9d72563aa2ee22e21797fb1d003f5db5e78d8629..856db875e449a883846a50a2909e322a4650ef1e 100644 (file)
@@ -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);
index 921dbfadd5ec0f26c847e1e55805136362425501..c721a79ea789e24c94e16c3596dfa2ca246aa607 100644 (file)
@@ -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