Fix some warnings on 64 bit systems with fr*king gcc-4.

This commit is contained in:
Kris Maglione 2008-01-31 16:32:24 -05:00
parent 0aa7f3b4fe
commit e9d2f3286b
6 changed files with 10 additions and 10 deletions

View File

@ -15,7 +15,7 @@ toutf8n(const char *str, size_t nstr) {
if(cd == nil) {
cd = iconv_open("UTF-8", nl_langinfo(CODESET));
if((int)cd == -1)
if((long)cd == -1)
warning("Can't convert from local character encoding to UTF-8");
else
haveiconv = true;

View File

@ -40,7 +40,7 @@ fmtfdinit(Fmt *f, int fd, char *buf, int size)
f->to = buf;
f->stop = buf + size;
f->flush = __fmtFdFlush;
f->farg = (void*)fd;
f->farg = (void*)(uintptr_t)fd;
f->nfmt = 0;
return 0;
}

View File

@ -27,7 +27,7 @@ __fmtFdFlush(Fmt *f)
int n;
n = (char*)f->to - (char*)f->start;
if(n && write((int)f->farg, f->start, n) != n)
if(n && write((uintptr_t)f->farg, f->start, n) != n)
return 0;
f->to = f->start;
return 1;

View File

@ -30,7 +30,7 @@ runeFmtStrFlush(Fmt *f)
if(f->start == nil)
return 0;
n = (int)f->farg;
n = (uintptr_t)f->farg;
n *= 2;
s = (Rune*)f->start;
f->start = realloc(s, sizeof(Rune)*n);
@ -41,7 +41,7 @@ runeFmtStrFlush(Fmt *f)
free(s);
return 0;
}
f->farg = (void*)n;
f->farg = (void*)(uintptr_t)n;
f->to = (Rune*)f->start + ((Rune*)f->to - s);
f->stop = (Rune*)f->start + n - 1;
return 1;
@ -61,7 +61,7 @@ runefmtstrinit(Fmt *f)
f->to = f->start;
f->stop = (Rune*)f->start + n - 1;
f->flush = runeFmtStrFlush;
f->farg = (void*)n;
f->farg = (void*)(uintptr_t)n;
f->nfmt = 0;
return 0;
}

View File

@ -28,7 +28,7 @@ sprint(char *buf, const char *fmt, ...)
* we must be sure not to overflow a 32-bit pointer.
*/
if(buf+len < buf)
len = -(uint)buf-1;
len = -(uintptr_t)buf-1;
va_start(args, fmt);
n = vsnprint(buf, len, fmt, args);

View File

@ -30,7 +30,7 @@ fmtStrFlush(Fmt *f)
if(f->start == nil)
return 0;
n = (int)f->farg;
n = (uintptr_t)f->farg;
n *= 2;
s = (char*)f->start;
f->start = realloc(s, n);
@ -41,7 +41,7 @@ fmtStrFlush(Fmt *f)
free(s);
return 0;
}
f->farg = (void*)n;
f->farg = (void*)(uintptr_t)n;
f->to = (char*)f->start + ((char*)f->to - s);
f->stop = (char*)f->start + n - 1;
return 1;
@ -61,7 +61,7 @@ fmtstrinit(Fmt *f)
f->to = f->start;
f->stop = (char*)f->start + n - 1;
f->flush = fmtStrFlush;
f->farg = (void*)n;
f->farg = (void*)(uintptr_t)n;
f->nfmt = 0;
return 0;
}