mirror of
https://github.com/curl/curl.git
synced 2025-02-17 14:59:45 +08:00
lib: silence -Wsign-conversion
in base64, strcase, mprintf
Closes #13467
This commit is contained in:
parent
1972588d26
commit
03cf1c7b8c
@ -243,7 +243,7 @@ static CURLcode base64_encode(const char *table64,
|
||||
*outptr = base64data;
|
||||
|
||||
/* Return the length of the new data */
|
||||
*outlen = output - base64data;
|
||||
*outlen = (size_t)(output - base64data);
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
#define OUTCHAR(x) \
|
||||
do { \
|
||||
if(!stream(x, userp)) \
|
||||
if(!stream((unsigned char)x, userp)) \
|
||||
done++; \
|
||||
else \
|
||||
return done; /* return on failure */ \
|
||||
@ -243,7 +243,7 @@ static int parsefmt(const char *format,
|
||||
struct va_input *iptr;
|
||||
bool loopit = TRUE;
|
||||
fmt++;
|
||||
outlen = fmt - start - 1;
|
||||
outlen = (size_t)(fmt - start - 1);
|
||||
if(*fmt == '%') {
|
||||
/* this means a %% that should be output only as %. Create an output
|
||||
segment. */
|
||||
@ -261,7 +261,8 @@ static int parsefmt(const char *format,
|
||||
continue; /* while */
|
||||
}
|
||||
|
||||
flags = width = precision = 0;
|
||||
flags = 0;
|
||||
width = precision = 0;
|
||||
|
||||
if(use_dollar != DOLLAR_NOPE) {
|
||||
param = dollarstring(fmt, &fmt);
|
||||
@ -291,7 +292,7 @@ static int parsefmt(const char *format,
|
||||
break;
|
||||
case '-':
|
||||
flags |= FLAGS_LEFT;
|
||||
flags &= ~FLAGS_PAD_NIL;
|
||||
flags &= ~(unsigned int)FLAGS_PAD_NIL;
|
||||
break;
|
||||
case '#':
|
||||
flags |= FLAGS_ALT;
|
||||
@ -549,7 +550,7 @@ static int parsefmt(const char *format,
|
||||
optr = &out[ocount++];
|
||||
if(ocount > MAX_SEGMENTS)
|
||||
return PFMT_MANYSEGS;
|
||||
optr->input = param;
|
||||
optr->input = (unsigned int)param;
|
||||
optr->flags = flags;
|
||||
optr->width = width;
|
||||
optr->precision = precision;
|
||||
@ -562,7 +563,7 @@ static int parsefmt(const char *format,
|
||||
}
|
||||
|
||||
/* is there a trailing piece */
|
||||
outlen = fmt - start;
|
||||
outlen = (size_t)(fmt - start);
|
||||
if(outlen) {
|
||||
optr = &out[ocount++];
|
||||
if(ocount > MAX_SEGMENTS)
|
||||
@ -688,7 +689,7 @@ static int formatf(
|
||||
mp_intmax_t signed_num; /* Used to convert negative in positive. */
|
||||
char *w;
|
||||
size_t outlen = optr->outlen;
|
||||
int flags = optr->flags;
|
||||
unsigned int flags = optr->flags;
|
||||
|
||||
if(outlen) {
|
||||
char *str = optr->start;
|
||||
@ -710,7 +711,7 @@ static int formatf(
|
||||
else
|
||||
width = -width;
|
||||
flags |= FLAGS_LEFT;
|
||||
flags &= ~FLAGS_PAD_NIL;
|
||||
flags &= ~(unsigned int)FLAGS_PAD_NIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -867,7 +868,7 @@ number:
|
||||
str = nilstr;
|
||||
len = sizeof(nilstr) - 1;
|
||||
/* Disable quotes around (nil) */
|
||||
flags &= (~FLAGS_ALT);
|
||||
flags &= ~(unsigned int)FLAGS_ALT;
|
||||
}
|
||||
else {
|
||||
str = "";
|
||||
@ -886,13 +887,13 @@ number:
|
||||
if(flags & FLAGS_ALT)
|
||||
OUTCHAR('"');
|
||||
|
||||
if(!(flags&FLAGS_LEFT))
|
||||
if(!(flags & FLAGS_LEFT))
|
||||
while(width-- > 0)
|
||||
OUTCHAR(' ');
|
||||
|
||||
for(; len && *str; len--)
|
||||
OUTCHAR(*str++);
|
||||
if(flags&FLAGS_LEFT)
|
||||
if(flags & FLAGS_LEFT)
|
||||
while(width-- > 0)
|
||||
OUTCHAR(' ');
|
||||
|
||||
@ -952,12 +953,13 @@ number:
|
||||
*fptr = 0;
|
||||
|
||||
if(width >= 0) {
|
||||
size_t dlen;
|
||||
if(width >= (int)sizeof(work))
|
||||
width = sizeof(work)-1;
|
||||
/* RECURSIVE USAGE */
|
||||
len = curl_msnprintf(fptr, left, "%d", width);
|
||||
fptr += len;
|
||||
left -= len;
|
||||
dlen = (size_t)curl_msnprintf(fptr, left, "%d", width);
|
||||
fptr += dlen;
|
||||
left -= dlen;
|
||||
}
|
||||
if(prec >= 0) {
|
||||
/* for each digit in the integer part, we can have one less
|
||||
@ -965,7 +967,7 @@ number:
|
||||
size_t maxprec = sizeof(work) - 2;
|
||||
double val = iptr->val.dnum;
|
||||
if(width > 0 && prec <= width)
|
||||
maxprec -= width;
|
||||
maxprec -= (size_t)width;
|
||||
while(val >= 10.0) {
|
||||
val /= 10;
|
||||
maxprec--;
|
||||
@ -1039,7 +1041,7 @@ static int addbyter(unsigned char outc, void *f)
|
||||
struct nsprintf *infop = f;
|
||||
if(infop->length < infop->max) {
|
||||
/* only do this if we haven't reached max length yet */
|
||||
*infop->buffer++ = outc; /* store */
|
||||
*infop->buffer++ = (char)outc; /* store */
|
||||
infop->length++; /* we are now one byte larger */
|
||||
return 0; /* fputc() returns like this on success */
|
||||
}
|
||||
@ -1139,7 +1141,7 @@ char *curl_maprintf(const char *format, ...)
|
||||
static int storebuffer(unsigned char outc, void *f)
|
||||
{
|
||||
char **buffer = f;
|
||||
**buffer = outc;
|
||||
**buffer = (char)outc;
|
||||
(*buffer)++;
|
||||
return 0;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ static const unsigned char tolowermap[256] = {
|
||||
altered by the current locale. */
|
||||
char Curl_raw_toupper(char in)
|
||||
{
|
||||
return touppermap[(unsigned char) in];
|
||||
return (char)touppermap[(unsigned char) in];
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ char Curl_raw_toupper(char in)
|
||||
altered by the current locale. */
|
||||
char Curl_raw_tolower(char in)
|
||||
{
|
||||
return tolowermap[(unsigned char) in];
|
||||
return (char)tolowermap[(unsigned char) in];
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user