summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-25 16:34:03 -0400
committerRich Felker <dalias@aerifal.cx>2011-03-25 16:34:03 -0400
commit9ae8d5fc71a4b61ec826d58f03f7b543755fb1d4 (patch)
treea712bede2bb0cef734418927fee7704732628e83 /src
parenta37452430f93700aeb122d693959ad79d8e43ada (diff)
downloadmusl-9ae8d5fc71a4b61ec826d58f03f7b543755fb1d4.tar.gz
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')
-rw-r--r--src/locale/iconv.c22
-rw-r--r--src/misc/crypt.c4
-rw-r--r--src/multibyte/mbrtowc.c2
-rw-r--r--src/network/getaddrinfo.c2
-rw-r--r--src/signal/siglongjmp.c2
-rw-r--r--src/stdio/fputwc.c4
-rw-r--r--src/stdio/ungetwc.c2
-rw-r--r--src/stdio/vdprintf.c2
-rw-r--r--src/stdio/vfprintf.c2
-rw-r--r--src/stdio/vsnprintf.c4
-rw-r--r--src/stdio/vswprintf.c2
-rw-r--r--src/stdlib/strtold.c6
-rw-r--r--src/stdlib/strtoumax.c2
-rw-r--r--src/string/strcasecmp.c2
-rw-r--r--src/string/strcspn.c10
-rw-r--r--src/string/strncasecmp.c2
-rw-r--r--src/string/strncmp.c2
-rw-r--r--src/string/strspn.c10
-rw-r--r--src/string/strstr.c10
19 files changed, 44 insertions, 48 deletions
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
index ce2c364f..f9f80174 100644
--- a/src/locale/iconv.c
+++ b/src/locale/iconv.c
@@ -283,7 +283,7 @@ static const unsigned char charmaps[] =
-static int fuzzycmp(const char *a, const char *b)
+static int fuzzycmp(const unsigned char *a, const unsigned char *b)
{
for (; *a && *b; a++, b++) {
while (*a && (*a|32U)-'a'>26 && *a-'0'>10U) a++;
@@ -292,15 +292,15 @@ static int fuzzycmp(const char *a, const char *b)
return *a != *b;
}
-static size_t find_charmap(const char *name)
+static size_t find_charmap(const void *name)
{
const unsigned char *s;
for (s=charmaps; *s; ) {
if (!fuzzycmp(name, s)) {
- for (; *s; s+=strlen(s)+1);
+ for (; *s; s+=strlen((void *)s)+1);
return s+1-charmaps;
}
- s += strlen(s)+1;
+ s += strlen((void *)s)+1;
if (!*s) s += ((128-s[2])*s[1]+7)/8 + 3;
}
return -1;
@@ -440,7 +440,7 @@ size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
case UTF_32LE:
l = 4;
if (*inb < 4) goto starved;
- c = get_32(*in, type);
+ c = get_32((void *)*in, type);
}
if (c-0xd800u < 0x800u || c >= 0x110000u) goto ilseq;
break;
@@ -450,13 +450,13 @@ size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
case UTF_16LE:
l = 2;
if (*inb < 2) goto starved;
- c = get_16(*in, type);
+ c = get_16((void *)*in, type);
if ((unsigned)(c-0xdc00) < 0x400) goto ilseq;
if ((unsigned)(c-0xd800) < 0x400) {
if (type-UCS2BE < 2U) goto ilseq;
l = 4;
if (*inb < 4) goto starved;
- d = get_16(*in + 2, from);
+ d = get_16((void *)(*in + 2), from);
if ((unsigned)(c-0xdc00) >= 0x400) goto ilseq;
c = ((c-0xd800)<<10) | (d-0xdc00);
}
@@ -531,22 +531,22 @@ size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
case UTF_16LE:
if (c < 0x10000) {
if (*outb < 2) goto toobig;
- put_16(*out, c, totype);
+ put_16((void *)*out, c, totype);
*out += 2;
*outb -= 2;
break;
}
if (type-UCS2BE < 2U) goto ilseq;
if (*outb < 4) goto toobig;
- put_16(*out, (c>>10)|0xd800, totype);
- put_16(*out + 2, (c&0x3ff)|0xdc00, totype);
+ put_16((void *)*out, (c>>10)|0xd800, totype);
+ put_16((void *)(*out + 2), (c&0x3ff)|0xdc00, totype);
*out += 4;
*outb -= 4;
break;
case UTF_32BE:
case UTF_32LE:
if (*outb < 4) goto toobig;
- put_32(*out, c, totype);
+ put_32((void *)*out, c, totype);
*out += 4;
*outb -= 4;
break;
diff --git a/src/misc/crypt.c b/src/misc/crypt.c
index 42918ef0..f50aadf2 100644
--- a/src/misc/crypt.c
+++ b/src/misc/crypt.c
@@ -2488,7 +2488,7 @@ des_crypt(struct des_ctx *ctx, char output[DES_OUT_BUFSIZE],
key++;
q++;
}
- des_setkey(ctx, (char *)keybuf);
+ des_setkey(ctx, (void *)keybuf);
/*
* setting - 2 bytes of salt
@@ -2566,7 +2566,7 @@ char *__crypt_r(const char *clear, const char *salt, struct crypt_data *data)
#endif
des_init(&des_ctx);
- return des_crypt(&des_ctx, (char *)data, clear, salt);
+ return des_crypt(&des_ctx, (char *)data, (void *)clear, (void *)salt);
}
weak_alias(__crypt_r, crypt_r);
diff --git a/src/multibyte/mbrtowc.c b/src/multibyte/mbrtowc.c
index a354573a..291537f8 100644
--- a/src/multibyte/mbrtowc.c
+++ b/src/multibyte/mbrtowc.c
@@ -22,7 +22,7 @@ size_t mbrtowc(wchar_t *wc, const char *src, size_t n, mbstate_t *st)
c = *(unsigned *)st;
if (!s) {
- s = "";
+ s = (void *)"";
wc = (void *)&wc;
n = 1;
} else if (!wc) wc = (void *)&wc;
diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index 90e85f6a..8126236b 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -13,7 +13,7 @@ static int is_valid(const char *host)
{
const unsigned char *s;
if (strlen(host)-1 > 254 || mbstowcs(0, host, 0) > 255) return 0;
- for (s=host; *s>=0x80 || *s=='.' || *s=='-' || isalnum(*s); s++);
+ for (s=(void *)host; *s>=0x80 || *s=='.' || *s=='-' || isalnum(*s); s++);
return !*s;
}
diff --git a/src/signal/siglongjmp.c b/src/signal/siglongjmp.c
index 33ac30ea..17129175 100644
--- a/src/signal/siglongjmp.c
+++ b/src/signal/siglongjmp.c
@@ -4,7 +4,7 @@
void siglongjmp(sigjmp_buf buf, int ret)
{
- long *flag = buf + sizeof(jmp_buf)/sizeof(long);
+ unsigned long *flag = buf + sizeof(jmp_buf)/sizeof(long);
sigset_t *mask = (void *)(flag + 1);
if (*flag)
sigprocmask (SIG_SETMASK, mask, NULL);
diff --git a/src/stdio/fputwc.c b/src/stdio/fputwc.c
index b48bb74d..ec49b5c6 100644
--- a/src/stdio/fputwc.c
+++ b/src/stdio/fputwc.c
@@ -11,12 +11,12 @@ wint_t __fputwc_unlocked(wchar_t c, FILE *f)
if (c != f->lbf && f->wpos + 1 < f->wend) *f->wpos++ = c;
else c = __overflow(f, c);
} else if (f->wpos + MB_LEN_MAX < f->wend) {
- l = wctomb(f->wpos, c);
+ l = wctomb((void *)f->wpos, c);
if (l < 0) c = WEOF;
else f->wpos += l;
} else {
l = wctomb(mbc, c);
- if (l < 0 || __fwritex(mbc, l, f) < l) c = WEOF;
+ if (l < 0 || __fwritex((void *)mbc, l, f) < l) c = WEOF;
}
return c;
}
diff --git a/src/stdio/ungetwc.c b/src/stdio/ungetwc.c
index f7cde2e0..6871d034 100644
--- a/src/stdio/ungetwc.c
+++ b/src/stdio/ungetwc.c
@@ -8,7 +8,7 @@ wint_t ungetwc(wint_t c, FILE *f)
if (c == WEOF) return c;
/* Try conversion early so we can fail without locking if invalid */
- if (!isascii(c) && (l = wctomb(mbc, c)) < 0)
+ if (!isascii(c) && (l = wctomb((void *)mbc, c)) < 0)
return WEOF;
FLOCK(f);
diff --git a/src/stdio/vdprintf.c b/src/stdio/vdprintf.c
index 35ed6e0b..68562e05 100644
--- a/src/stdio/vdprintf.c
+++ b/src/stdio/vdprintf.c
@@ -8,7 +8,7 @@ static size_t wrap_write(FILE *f, const unsigned char *buf, size_t len)
int vdprintf(int fd, const char *fmt, va_list ap)
{
int r;
- char buf[BUFSIZ];
+ unsigned char buf[BUFSIZ];
FILE f = {
.fd = fd, .lbf = EOF, .write = wrap_write,
.buf = buf+UNGET, .buf_size = sizeof buf - UNGET
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index 19afd6c9..b6bb3bcf 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -149,7 +149,7 @@ static void pop_arg(union arg *arg, int type, va_list *ap)
static void out(FILE *f, const char *s, size_t l)
{
- __fwritex(s, l, f);
+ __fwritex((void *)s, l, f);
}
static void pad(FILE *f, char c, int w, int l, int fl)
diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c
index 5d3f0c5f..1f316ca4 100644
--- a/src/stdio/vsnprintf.c
+++ b/src/stdio/vsnprintf.c
@@ -23,8 +23,8 @@ int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
return -1;
} else if (n > 0) {
if (n > (char *)0+SIZE_MAX-s) n = (char *)0+SIZE_MAX-s;
- f.wpos = s;
- f.wbase = f.wend = s+n-1;
+ f.wpos = (void *)s;
+ f.wbase = f.wend = (void *)(s+n-1);
f.wstop = f.wend - 1;
}
r = vfprintf(&f, fmt, ap);
diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c
index 31ea1875..2d9f2002 100644
--- a/src/stdio/vswprintf.c
+++ b/src/stdio/vswprintf.c
@@ -10,7 +10,7 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l)
size_t l0 = l;
int i = 0;
struct cookie *c = f->cookie;
- while (c->l && l && (i=mbtowc(c->ws, s, l))>=0) {
+ while (c->l && l && (i=mbtowc(c->ws, (void *)s, l))>=0) {
s+=i;
l-=i;
c->l--;
diff --git a/src/stdlib/strtold.c b/src/stdlib/strtold.c
index 54f80469..73f2b082 100644
--- a/src/stdlib/strtold.c
+++ b/src/stdlib/strtold.c
@@ -4,7 +4,7 @@
long double strtold(const char *s1, char **p)
{
- const unsigned char *s = s1;
+ const unsigned char *s = (void *)s1;
long double x = 0;
long double frac;
int sign = 0;
@@ -53,7 +53,7 @@ long double strtold(const char *s1, char **p)
}
}
if ((*s|32) == 'p') {
- e = strtol(s+1, (void *)&s, 10);
+ e = strtol((void *)(s+1), (void *)&s, 10);
for (; e>0; e--) x *= 2.0;
for (; e<0; e++) x *= 0.5;
}
@@ -82,7 +82,7 @@ long double strtold(const char *s1, char **p)
}
}
if ((*s|32)=='e') {
- e = strtol(++s, (void *)&s, 10);
+ e = strtol((void *)++s, (void *)&s, 10);
for (; e>0; e--) x *= 10.0;
for (; e<0; e++) x /= 10.0;
}
diff --git a/src/stdlib/strtoumax.c b/src/stdlib/strtoumax.c
index a529f6e8..f1902476 100644
--- a/src/stdlib/strtoumax.c
+++ b/src/stdlib/strtoumax.c
@@ -26,7 +26,7 @@ static const unsigned char digits[] = {
uintmax_t strtoumax(const char *s1, char **p, int base)
{
- const unsigned char *s = s1;
+ const unsigned char *s = (void *)s1;
size_t x1, z1;
uintmax_t x, z=0;
int sign = 0;
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);
}