remove compiler warnings

master
leitner 11 years ago
parent 01ffc04006
commit 9a1addce2f

@ -12,5 +12,5 @@ size_t byte_chr(const void* haystack, size_t len, char needle) {
if (s==t) break; if (*s==c) break; ++s; if (s==t) break; if (*s==c) break; ++s;
if (s==t) break; if (*s==c) break; ++s; if (s==t) break; if (*s==c) break; ++s;
} }
return s-(const char*)haystack; return (size_t)(s-(const char*)haystack);
} }

@ -7,10 +7,10 @@ size_t byte_rchr(const void* haystack,size_t len,char needle) {
register const char* s=haystack; register const char* s=haystack;
register const char* t=s+len; register const char* t=s+len;
for (;;) { for (;;) {
--t; if (s>t) break; if (*t==c) return t-s; --t; if (s>t) break; if (*t==c) return (size_t)(t-s);
--t; if (s>t) break; if (*t==c) return t-s; --t; if (s>t) break; if (*t==c) return (size_t)(t-s);
--t; if (s>t) break; if (*t==c) return t-s; --t; if (s>t) break; if (*t==c) return (size_t)(t-s);
--t; if (s>t) break; if (*t==c) return t-s; --t; if (s>t) break; if (*t==c) return (size_t)(t-s);
} }
return len; return len;
} }

@ -6,7 +6,7 @@ size_t fmt_8long(char *dest,unsigned long i) {
for (len=1, tmp=i; tmp>7; ++len) tmp>>=3; for (len=1, tmp=i; tmp>7; ++len) tmp>>=3;
if (dest) if (dest)
for (tmp=i, dest+=len; ; ) { for (tmp=i, dest+=len; ; ) {
*--dest = (tmp&7)+'0'; *--dest = (char)((tmp&7)+'0');
if (!(tmp>>=3)) break; if (!(tmp>>=3)) break;
} }
return len; return len;

@ -7,7 +7,7 @@ size_t fmt_8longlong(char *dest,unsigned long long i) {
for (len=1, tmp=i; tmp>7; ++len) tmp>>=3; for (len=1, tmp=i; tmp>7; ++len) tmp>>=3;
if (dest) if (dest)
for (tmp=i, dest+=len; ; ) { for (tmp=i, dest+=len; ; ) {
*--dest = (tmp&7)+'0'; *--dest = (char)((tmp&7)+'0');
if (!(tmp>>=3)) break; if (!(tmp>>=3)) break;
} }
return len; return len;

@ -13,11 +13,11 @@ size_t fmt_asn1derlength(char* dest,unsigned long long l) {
if (!(l>>(i*8))) if (!(l>>(i*8)))
break; break;
if (dest) { if (dest) {
int j=i; size_t j=i;
*dest=0x80+i; ++dest; *dest=(char)(0x80+i); ++dest;
while (j) { while (j) {
--j; --j;
*dest=((l>>(j*8))&0xff); *dest=(char)((l>>(j*8))&0xff);
++dest; ++dest;
} }
} }

@ -8,7 +8,7 @@ size_t fmt_asn1dertag(char* dest,unsigned long long l) {
unsigned long long t; unsigned long long t;
for (t=l, n=1; t>0x7f; t>>=7) ++n; for (t=l, n=1; t>0x7f; t>>=7) ++n;
for (i=0; i<n; ++i) { for (i=0; i<n; ++i) {
if (dest) dest[n-i-1]=((i!=0)<<7) | (l&0x7f); if (dest) dest[n-i-1]=(char)(((i!=0)<<7) | (char)(l&0x7f));
l>>=7; l>>=7;
} }
return i; return i;

@ -1,9 +1,9 @@
#include "fmt.h" #include "fmt.h"
static void fmt_oct3(char* dest,uint8_t w) { static void fmt_oct3(char* dest,uint8_t w) {
dest[2]=(w&7)+'0'; w>>=3; dest[2]=(char)((w&7)+'0'); w>>=3;
dest[1]=(w&7)+'0'; w>>=3; dest[1]=(char)((w&7)+'0'); w>>=3;
dest[0]=(w&7)+'0'; dest[0]=(char)((w&7)+'0');
} }
size_t fmt_escapecharc(char* dest,uint32_t ch) { size_t fmt_escapecharc(char* dest,uint32_t ch) {

@ -22,7 +22,7 @@ size_t fmt_escapecharjson(char* dest,uint32_t ch) {
simple: simple:
if (dest) { if (dest) {
dest[0]='\\'; dest[0]='\\';
dest[1]=ch; dest[1]=(char)ch;
} }
return 2; return 2;
} }
@ -31,7 +31,7 @@ simple:
if (dest) { if (dest) {
dest[0]='\\'; dest[0]='\\';
dest[1]='u'; dest[1]='u';
fmt_hex4(dest+2,0xd800 | (((ch-0x10000)>>10)&0x3ff)); fmt_hex4(dest+2,(uint16_t)(0xd800 | (((ch-0x10000)>>10)&0x3ff)));
dest+=6; dest+=6;
} }
ch=(ch&0x3ff)|0xdc00; ch=(ch&0x3ff)|0xdc00;
@ -41,7 +41,7 @@ simple:
if (dest) { if (dest) {
dest[0]='\\'; dest[0]='\\';
dest[1]='u'; dest[1]='u';
fmt_hex4(dest+2,ch); fmt_hex4(dest+2,(uint16_t)ch);
} }
return n+6; return n+6;
} }

@ -19,5 +19,5 @@ size_t fmt_fill(char* dest,size_t srclen,size_t padlen,size_t maxlen) {
if (dest>max) break; if (dest>max) break;
*dest=' '; ++dest; *dest=' '; ++dest;
} }
return dest-olddest; return (size_t)(dest-olddest);
} }

@ -3,8 +3,8 @@
#include <time.h> #include <time.h>
static unsigned int fmt_2digits(char* dest,int i) { static unsigned int fmt_2digits(char* dest,int i) {
dest[0]=(i/10)+'0'; dest[0]=(char)((i/10)+'0');
dest[1]=(i%10)+'0'; dest[1]=(char)((i%10)+'0');
return 2; return 2;
} }

@ -2,7 +2,7 @@
size_t fmt_human(char* dest,unsigned long long l) { size_t fmt_human(char* dest,unsigned long long l) {
char unit; char unit;
int i; size_t i;
if (l<1000) return fmt_ulong(dest,l); if (l<1000) return fmt_ulong(dest,l);
if (l>1000000000000ull) { if (l>1000000000000ull) {
/* dang! overflow! */ /* dang! overflow! */
@ -22,7 +22,7 @@ size_t fmt_human(char* dest,unsigned long long l) {
if (!dest) return fmt_ulong(0,l)+2; if (!dest) return fmt_ulong(0,l)+2;
i=fmt_ulong(dest,l/10); i=fmt_ulong(dest,l/10);
dest[i]='.'; dest[i]='.';
dest[i+1]=(l%10)+'0'; dest[i+1]=(char)((l%10)+'0');
dest[i+2]=unit; dest[i+2]=unit;
return i+3; return i+3;
} }

@ -20,7 +20,7 @@ size_t fmt_humank(char* dest,unsigned long long l) {
if (!dest) return fmt_ulong(0,l)+2; if (!dest) return fmt_ulong(0,l)+2;
i=fmt_ulong(dest,l/10); i=fmt_ulong(dest,l/10);
dest[i]='.'; dest[i]='.';
dest[i+1]=(l%10)+'0'; dest[i+1]=(char)((l%10)+'0');
dest[i+2]=unit; dest[i+2]=unit;
return i+3; return i+3;
} }

@ -3,7 +3,7 @@
size_t fmt_long(char *dest,long int i) { size_t fmt_long(char *dest,long int i) {
if (i<0) { if (i<0) {
if (dest) *dest++='-'; if (dest) *dest++='-';
return fmt_ulong(dest,-i)+1; return fmt_ulong(dest,(unsigned long)-i)+1;
} else } else
return fmt_ulong(dest,i); return fmt_ulong(dest,(unsigned long)i);
} }

@ -18,7 +18,7 @@ size_t fmt_pad(char* dest,const char* src,size_t srclen,size_t padlen,size_t max
if (dest>max) break; if (dest>max) break;
*dest=' '; ++dest; *dest=' '; ++dest;
} }
for (todo=(long)srclen>maxlen?maxlen:srclen; todo>0; --todo) { for (todo=(long)(srclen>maxlen?maxlen:srclen); todo>0; --todo) {
if (dest>max) break; if (dest>max) break;
*dest=*src; ++dest; ++src; *dest=*src; ++dest; ++src;
} }

@ -10,5 +10,5 @@ size_t fmt_strn(char *out,const char *in,size_t limit) {
if (!*t || t==u) break; if (s) { *s=*t; ++s; } ++t; if (!*t || t==u) break; if (s) { *s=*t; ++s; } ++t;
if (!*t || t==u) break; if (s) { *s=*t; ++s; } ++t; if (!*t || t==u) break; if (s) { *s=*t; ++s; } ++t;
} }
return t-in; return (size_t)(t-in);
} }

@ -1,6 +1,6 @@
#include "fmt.h" #include "fmt.h"
char fmt_tohex(char c) { char fmt_tohex(char c) {
return c>=10?c-10+'a':c+'0'; return (char)(c>=10?c-10+'a':c+'0');
} }

@ -6,6 +6,6 @@ size_t fmt_ulong(char *dest,unsigned long i) {
for (len=1, tmp=i; tmp>9; ++len) tmp/=10; for (len=1, tmp=i; tmp>9; ++len) tmp/=10;
if (dest) if (dest)
for (tmp=i, dest+=len, len2=len+1; --len2; tmp/=10) for (tmp=i, dest+=len, len2=len+1; --len2; tmp/=10)
*--dest = (tmp%10)+'0'; *--dest = (char)((tmp%10)+'0');
return len; return len;
} }

@ -7,6 +7,6 @@ size_t fmt_ulonglong(char *dest,unsigned long long int i) {
for (len=1, tmp=i; tmp>9; ++len) tmp/=10; for (len=1, tmp=i; tmp>9; ++len) tmp/=10;
if (dest) if (dest)
for (tmp=i, dest+=len, len2=len+1; --len2; tmp/=10) for (tmp=i, dest+=len, len2=len+1; --len2; tmp/=10)
*--dest = (tmp%10)+'0'; *--dest = (char)((tmp%10)+'0');
return len; return len;
} }

@ -2,7 +2,7 @@
#include "haveinline.h" #include "haveinline.h"
static inline char tohex(char c) { static inline char tohex(char c) {
return c>=10?c-10+'a':c+'0'; return (char)(c>=10?c-10+'a':c+'0');
} }
size_t fmt_xlong(char *dest,unsigned long i) { size_t fmt_xlong(char *dest,unsigned long i) {

@ -1,7 +1,7 @@
#include "fmt.h" #include "fmt.h"
static inline char tohex(char c) { static inline char tohex(char c) {
return c>=10?c-10+'a':c+'0'; return (char)(c>=10?c-10+'a':c+'0');
} }
size_t fmt_xlonglong(char *dest,unsigned long long i) { size_t fmt_xlonglong(char *dest,unsigned long long i) {

Loading…
Cancel
Save