r6149: Fixes bugs #2498 and 2484.
[samba.git] / source / lib / util_unistr.c
index 04985c6ab6a2ea95a77b5887c137ac5f64fc6940..0b4552e1f5d918b0046cee8a534e0182a4f60384 100644 (file)
@@ -398,10 +398,10 @@ size_t strnlen_w(const smb_ucs2_t *src, size_t max)
 smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c)
 {
        while (*s != 0) {
-               if (c == *s) return (smb_ucs2_t *)s;
+                if (c == *s) return CONST_DISCARD(smb_ucs2_t *, s);
                s++;
        }
-       if (c == *s) return (smb_ucs2_t *)s;
+       if (c == *s) return CONST_DISCARD(smb_ucs2_t *, s);
 
        return NULL;
 }
@@ -422,7 +422,7 @@ smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c)
        if (len == 0) return NULL;
        p += (len - 1);
        do {
-               if (c == *p) return (smb_ucs2_t *)p;
+               if (c == *p) return CONST_DISCARD(smb_ucs2_t *, p);
        } while (p-- != s);
        return NULL;
 }
@@ -443,7 +443,7 @@ smb_ucs2_t *strnrchr_w(const smb_ucs2_t *s, smb_ucs2_t c, unsigned int n)
                        n--;
 
                if (!n)
-                       return (smb_ucs2_t *)p;
+                       return CONST_DISCARD(smb_ucs2_t *, p);
        } while (p-- != s);
        return NULL;
 }
@@ -461,7 +461,7 @@ smb_ucs2_t *strstr_w(const smb_ucs2_t *s, const smb_ucs2_t *ins)
                return NULL;
 
        inslen = strlen_w(ins);
-       r = (smb_ucs2_t *)s;
+       r = CONST_DISCARD(smb_ucs2_t *, s);
 
        while ((r = strchr_w(r, *ins))) {
                if (strncmp_w(r, ins, inslen) == 0) 
@@ -732,7 +732,7 @@ smb_ucs2_t *strpbrk_wa(const smb_ucs2_t *s, const char *p)
                int i;
                for (i=0; p[i] && *s != UCS2_CHAR(p[i]); i++) 
                        ;
-               if (p[i]) return (smb_ucs2_t *)s;
+               if (p[i]) return CONST_DISCARD(smb_ucs2_t *, s);
                s++;
        }
        return NULL;
@@ -747,7 +747,7 @@ smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins)
                return NULL;
 
        inslen = strlen(ins);
-       r = (smb_ucs2_t *)s;
+       r = CONST_DISCARD(smb_ucs2_t *, s);
 
        while ((r = strchr_w(r, UCS2_CHAR(*ins)))) {
                if (strncmp_wa(r, ins, inslen) == 0)