]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Disable lib/string wprintf functions for non-Windows builds
authorOliver Kurth <okurth@vmware.com>
Mon, 23 Oct 2017 21:21:19 +0000 (14:21 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 23 Oct 2017 21:21:19 +0000 (14:21 -0700)
The lib/string wprintf functions currently are enabled only
for Windows and Linux builds, but Windows is the only
platform that uses them.  Disable them for Linux, too.

This also means HAS_BSD_WPRINTF can be removed.

open-vm-tools/lib/include/str.h
open-vm-tools/lib/string/str.c

index 89889406f7c49b60c7c67258c724c663e602cf4a..3f3d24f298271b474e0308a326b37879763915c5 100644 (file)
@@ -63,7 +63,11 @@ extern "C" {
 
 /*
  * These platforms use bsd_vsnprintf().
- * This does not mean it has bsd_vsnwprintf().
+ *
+ * XXX: open-vm-tools does not use bsd_vsnprintf because bsd_vsnprintf uses
+ * convertutf.{h,c}, and the license for those files does not meet the
+ * redistribution requirements for Debian.
+ * <https://github.com/vmware/open-vm-tools/issues/148>
  */
 #if !defined(OPEN_VM_TOOLS)
 #if (defined _WIN32 && !defined STR_NO_WIN32_LIBS) || \
@@ -73,17 +77,6 @@ extern "C" {
 #endif
 #endif
 
-/*
- * And these platforms/setups use bsd_vsnwprintf()
- */
-#if !defined(OPEN_VM_TOOLS)
-#if (defined _WIN32 && !defined STR_NO_WIN32_LIBS) || \
-   (defined __GNUC__ && (__GNUC__ < 2                 \
-                         || (__GNUC__ == 2            \
-                             && __GNUC_MINOR__ < 96)))
-#define HAS_BSD_WPRINTF 1
-#endif
-#endif
 
 /*
  * ASCII/UTF-8 versions
@@ -146,7 +139,7 @@ char *Str_SafeVasprintf(size_t *length,      // OUT/OPT:
                         const char *format,  // IN:
                         va_list arguments);  // IN:
 
-#if defined(_WIN32) || defined(__linux__) // {
+#if defined(_WIN32) // {
 
 /*
  * wchar_t versions
@@ -202,7 +195,6 @@ wchar_t *Str_SafeVaswprintf(size_t *length,         // OUT/OPT:
  * the _tcs functions, but with Str_Strcpy-style bounds checking.
  */
 
-#ifdef _WIN32
 #ifdef UNICODE
    #define Str_Tcscpy(s1, s2, n) Str_Wcscpy(s1, s2, n)
    #define Str_Tcscat(s1, s2, n) Str_Wcscat(s1, s2, n)
@@ -210,9 +202,8 @@ wchar_t *Str_SafeVaswprintf(size_t *length,         // OUT/OPT:
    #define Str_Tcscpy(s1, s2, n) Str_Strcpy(s1, s2, n)
    #define Str_Tcscat(s1, s2, n) Str_Strcat(s1, s2, n)
 #endif
-#endif
 
-#endif // } defined(_WIN32) || defined(__linux__)
+#endif // } defined(_WIN32)
 
 
 /*
index a295ea2c2ba32ba27c93b4fa36f9551774a62612..c201bc6d73d4072e9bbd20956802fabcccaf91a0 100644 (file)
@@ -685,7 +685,7 @@ Str_SafeVasprintf(size_t *length,       // OUT/OPT
    return StrVasprintfInternal(length, format, arguments, TRUE);
 }
 
-#if defined(_WIN32) || defined(__linux__)
+#if defined(_WIN32) // {
 
 /*
  *----------------------------------------------------------------------
@@ -698,7 +698,7 @@ Str_SafeVasprintf(size_t *length,       // OUT/OPT
  *      Returns the number of wchar_ts stored in 'buf'.
  *
  * WARNING:
- *      Behavior of this function is guaranteed only if HAS_BSD_WPRINTF is
+ *      Behavior of this function is guaranteed only if HAS_BSD_PRINTF is
  *      enabled.
  *
  * Side effects:
@@ -742,7 +742,7 @@ Str_Swprintf(wchar_t *buf,       // OUT
  *      NB: on overflow the buffer WILL be NUL terminated
  *
  * WARNING:
- *      Behavior of this function is guaranteed only if HAS_BSD_WPRINTF is
+ *      Behavior of this function is guaranteed only if HAS_BSD_PRINTF is
  *      enabled.
  *
  *      See the warning at the top of this file for proper va_list usage.
@@ -761,7 +761,7 @@ Str_Vsnwprintf(wchar_t *str,          // OUT
 {
    int retval;
 
-#if defined HAS_BSD_WPRINTF
+#if defined HAS_BSD_PRINTF
    retval = bsd_vsnwprintf(&str, size, format, ap);
 #elif defined(_WIN32)
    /*
@@ -1146,7 +1146,7 @@ Str_SafeVaswprintf(size_t *length,         // OUT/OPT
    return StrVaswprintfInternal(length, format, arguments, TRUE);
 }
 
-#endif // defined(_WIN32) || defined(__linux__)
+#endif // } defined(_WIN32)
 
 #ifndef _WIN32
 
@@ -1269,7 +1269,7 @@ CheckWPrintf(const wchar_t *expected, // IN
              const wchar_t *fmt,      // IN
              ...)                     // IN
 {
-#if !defined HAS_BSD_WPRINTF
+#if !defined HAS_BSD_PRINTF
    NOT_TESTED_ONCE();
 #else
    wchar_t buf[1024] = L"";