diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-03-25 16:34:03 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-03-25 16:34:03 -0400 |
commit | 9ae8d5fc71a4b61ec826d58f03f7b543755fb1d4 (patch) | |
tree | a712bede2bb0cef734418927fee7704732628e83 /src/string | |
parent | a37452430f93700aeb122d693959ad79d8e43ada (diff) | |
download | musl-9ae8d5fc71a4b61ec826d58f03f7b543755fb1d4.tar.gz musl-9ae8d5fc71a4b61ec826d58f03f7b543755fb1d4.tar.bz2 musl-9ae8d5fc71a4b61ec826d58f03f7b543755fb1d4.tar.xz musl-9ae8d5fc71a4b61ec826d58f03f7b543755fb1d4.zip |
fix all implicit conversion between signed/unsigned pointers
sadly the C language does not specify any such implicit conversion, so
this is not a matter of just fixing warnings (as gcc treats it) but
actual errors. i would like to revisit a number of these changes and
possibly revise the types used to reduce the number of casts required.
Diffstat (limited to 'src/string')
-rw-r--r-- | src/string/strcasecmp.c | 2 | ||||
-rw-r--r-- | src/string/strcspn.c | 10 | ||||
-rw-r--r-- | src/string/strncasecmp.c | 2 | ||||
-rw-r--r-- | src/string/strncmp.c | 2 | ||||
-rw-r--r-- | src/string/strspn.c | 10 | ||||
-rw-r--r-- | src/string/strstr.c | 10 |
6 files changed, 16 insertions, 20 deletions
diff --git a/src/string/strcasecmp.c b/src/string/strcasecmp.c index dd879052..02fd5f8c 100644 --- a/src/string/strcasecmp.c +++ b/src/string/strcasecmp.c @@ -3,7 +3,7 @@ int strcasecmp(const char *_l, const char *_r) { - const unsigned char *l=_l, *r=_r; + const unsigned char *l=(void *)_l, *r=(void *)_r; for (; *l && *r && (*l == *r || tolower(*l) == tolower(*r)); l++, r++); return tolower(*l) - tolower(*r); } diff --git a/src/string/strcspn.c b/src/string/strcspn.c index 439b7be4..c843ff97 100644 --- a/src/string/strcspn.c +++ b/src/string/strcspn.c @@ -3,18 +3,16 @@ #define BITOP(a,b,op) \ ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) -size_t strcspn(const char *_s, const char *_c) +size_t strcspn(const char *s, const char *c) { - const unsigned char *s = _s; - const unsigned char *c = _c; - const unsigned char *a = s; + const char *a = s; size_t byteset[32/sizeof(size_t)]; if (!c[0]) return strlen(s); if (!c[1]) return (s=strchr(s, *c)) ? s-a : strlen(a); memset(byteset, 0, sizeof byteset); - for (; *c && BITOP(byteset, *c, |=); c++); - for (; *s && !BITOP(byteset, *s, &); s++); + for (; *c && BITOP(byteset, *(unsigned char *)c, |=); c++); + for (; *s && !BITOP(byteset, *(unsigned char *)s, &); s++); return s-a; } diff --git a/src/string/strncasecmp.c b/src/string/strncasecmp.c index 4f9230e1..24659721 100644 --- a/src/string/strncasecmp.c +++ b/src/string/strncasecmp.c @@ -3,7 +3,7 @@ int strncasecmp(const char *_l, const char *_r, size_t n) { - const unsigned char *l=_l, *r=_r; + const unsigned char *l=(void *)_l, *r=(void *)_r; if (!n--) return 0; for (; *l && *r && n && (*l == *r || tolower(*l) == tolower(*r)); l++, r++, n--); return tolower(*l) - tolower(*r); diff --git a/src/string/strncmp.c b/src/string/strncmp.c index 52ba0323..e228843f 100644 --- a/src/string/strncmp.c +++ b/src/string/strncmp.c @@ -2,7 +2,7 @@ int strncmp(const char *_l, const char *_r, size_t n) { - const unsigned char *l=_l, *r=_r; + const unsigned char *l=(void *)_l, *r=(void *)_r; if (!n--) return 0; for (; *l && *r && n && *l == *r ; l++, r++, n--); return *l - *r; diff --git a/src/string/strspn.c b/src/string/strspn.c index 59b063e5..9543dad0 100644 --- a/src/string/strspn.c +++ b/src/string/strspn.c @@ -3,11 +3,9 @@ #define BITOP(a,b,op) \ ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) -size_t strspn(const char *_s, const char *_c) +size_t strspn(const char *s, const char *c) { - const unsigned char *s = _s; - const unsigned char *c = _c; - const unsigned char *a = s; + const char *a = s; size_t byteset[32/sizeof(size_t)] = { 0 }; if (!c[0]) return 0; @@ -16,7 +14,7 @@ size_t strspn(const char *_s, const char *_c) return s-a; } - for (; *c && BITOP(byteset, *c, |=); c++); - for (; *s && BITOP(byteset, *s, &); s++); + for (; *c && BITOP(byteset, *(unsigned char *)c, |=); c++); + for (; *s && BITOP(byteset, *(unsigned char *)s, &); s++); return s-a; } diff --git a/src/string/strstr.c b/src/string/strstr.c index 4d536a73..683cdd01 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -109,7 +109,7 @@ static char *twoway_strstr(const unsigned char *h, const unsigned char *n) if (z-h < l) { /* Fast estimate for MIN(l,63) */ size_t grow = l | 63; - const char *z2 = memchr(z, 0, grow); + const unsigned char *z2 = memchr(z, 0, grow); if (z2) { z = z2; if (z-h < l) return 0; @@ -156,11 +156,11 @@ char *strstr(const char *h, const char *n) h = strchr(h, *n); if (!h || !n[1]) return (char *)h; if (!h[1]) return 0; - if (!n[2]) return twobyte_strstr(h, n); + if (!n[2]) return twobyte_strstr((void *)h, (void *)n); if (!h[2]) return 0; - if (!n[3]) return threebyte_strstr(h, n); + if (!n[3]) return threebyte_strstr((void *)h, (void *)n); if (!h[3]) return 0; - if (!n[4]) return fourbyte_strstr(h, n); + if (!n[4]) return fourbyte_strstr((void *)h, (void *)n); - return twoway_strstr(h, n); + return twoway_strstr((void *)h, (void *)n); } |