From 3a5bdbcbd72ab2874946fa92ab86f1cf6610cedb Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 24 Nov 2015 00:15:11 +0100 Subject: [PATCH 3/3] Fix warning: "pointer targets in passing argument 1 of '_mbsrchr' differ in signedness [-Wpointer-sign]". Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069 --- dbus/dbus-string.h | 5 +++++ dbus/dbus-sysdeps-win.c | 27 ++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h index 44ce5d2..ae2a238 100644 --- a/dbus/dbus-string.h +++ b/dbus/dbus-string.h @@ -361,6 +361,11 @@ dbus_bool_t _dbus_string_validate_nul (const DBusString *str, int len); void _dbus_string_zero (DBusString *str); +static inline unsigned char * +_dbus_string_get_udata (DBusString *str) +{ + return (unsigned char *) _dbus_string_get_data (str); +} static inline unsigned char * _dbus_string_get_udata_len (DBusString *str, int start, int len) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index d67f9e6..1a35a89 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2320,7 +2320,8 @@ _dbus_get_tmpdir(void) if (tmpdir == NULL) { - char *last_slash; + unsigned char *last_slash; + unsigned char *p = (unsigned char *)buf; if (!GetTempPathA (sizeof (buf), buf)) { @@ -2329,11 +2330,11 @@ _dbus_get_tmpdir(void) } /* Drop terminating backslash or slash */ - last_slash = _mbsrchr (buf, '\\'); - if (last_slash > buf && last_slash[1] == '\0') + last_slash = _mbsrchr (p, '\\'); + if (last_slash > p && last_slash[1] == '\0') last_slash[0] = '\0'; - last_slash = _mbsrchr (buf, '/'); - if (last_slash > buf && last_slash[1] == '\0') + last_slash = _mbsrchr (p, '/'); + if (last_slash > p && last_slash[1] == '\0') last_slash[0] = '\0'; tmpdir = buf; @@ -3197,8 +3198,8 @@ _dbus_get_install_root (DBusString *str) { /* this is just an initial guess */ DWORD pathLength = MAX_PATH; - char *lastSlash; - char *prefix; + unsigned char *lastSlash; + unsigned char *prefix; do { @@ -3241,9 +3242,9 @@ _dbus_get_install_root (DBusString *str) /* the rest of this function works by direct byte manipulation of the * underlying buffer */ - prefix = _dbus_string_get_data (str); + prefix = _dbus_string_get_udata (str); - lastSlash = _mbsrchr(prefix, '\\'); + lastSlash = _mbsrchr (prefix, '\\'); if (lastSlash == NULL) { /* failed, but not OOM */ _dbus_string_set_length (str, 0); @@ -3257,15 +3258,15 @@ _dbus_get_install_root (DBusString *str) //folder's name happens to end with the *bytes* //"\\bin"... (I.e. the second byte of some Han character and then //the Latin "bin", but that is not likely I think... - if (lastSlash - prefix >= 4 && strnicmp(lastSlash - 4, "\\bin", 4) == 0) + if (lastSlash - prefix >= 4 && _mbsnicmp (lastSlash - 4, (const unsigned char *)"\\bin", 4) == 0) lastSlash[-3] = 0; - else if (lastSlash - prefix >= 10 && strnicmp(lastSlash - 10, "\\bin\\debug", 10) == 0) + else if (lastSlash - prefix >= 10 && _mbsnicmp (lastSlash - 10, (const unsigned char *)"\\bin\\debug", 10) == 0) lastSlash[-9] = 0; - else if (lastSlash - prefix >= 12 && strnicmp(lastSlash - 12, "\\bin\\release", 12) == 0) + else if (lastSlash - prefix >= 12 && _mbsnicmp (lastSlash - 12, (const unsigned char *)"\\bin\\release", 12) == 0) lastSlash[-11] = 0; /* fix up the length to match the byte-manipulation */ - _dbus_string_set_length (str, strlen (prefix)); + _dbus_string_set_length (str, strlen ((char *) prefix)); return TRUE; } -- 1.8.4.5