mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-20 22:21:41 +00:00
lib: vsprintf.c: fix checkpath.pl warnings
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
This commit is contained in:
parent
b823fd9ba5
commit
8acdae681a
1 changed files with 77 additions and 50 deletions
|
@ -40,9 +40,11 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
|
unsigned long simple_strtoul(const char *cp, char **endp,
|
||||||
|
unsigned int base)
|
||||||
{
|
{
|
||||||
unsigned long result = 0,value;
|
unsigned long result = 0;
|
||||||
|
unsigned long value;
|
||||||
|
|
||||||
if (*cp == '0') {
|
if (*cp == '0') {
|
||||||
cp++;
|
cp++;
|
||||||
|
@ -50,20 +52,23 @@ unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
|
||||||
base = 16;
|
base = 16;
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
if (!base) {
|
|
||||||
|
if (!base)
|
||||||
base = 8;
|
base = 8;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!base) {
|
if (!base)
|
||||||
base = 10;
|
base = 10;
|
||||||
}
|
|
||||||
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
|
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
|
||||||
? toupper(*cp) : *cp)-'A'+10) < base) {
|
? toupper(*cp) : *cp)-'A'+10) < base) {
|
||||||
result = result*base + value;
|
result = result*base + value;
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endp)
|
if (endp)
|
||||||
*endp = (char *)cp;
|
*endp = (char *)cp;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +100,7 @@ long simple_strtol(const char *cp,char **endp,unsigned int base)
|
||||||
{
|
{
|
||||||
if (*cp == '-')
|
if (*cp == '-')
|
||||||
return -simple_strtoul(cp + 1, endp, base);
|
return -simple_strtoul(cp + 1, endp, base);
|
||||||
|
|
||||||
return simple_strtoul(cp, endp, base);
|
return simple_strtoul(cp, endp, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +127,8 @@ int ustrtoul(const char *cp, char **endp, unsigned int base)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int base)
|
unsigned long long simple_strtoull(const char *cp, char **endp,
|
||||||
|
unsigned int base)
|
||||||
{
|
{
|
||||||
unsigned long long result = 0, value;
|
unsigned long long result = 0, value;
|
||||||
|
|
||||||
|
@ -131,21 +138,23 @@ unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int ba
|
||||||
base = 16;
|
base = 16;
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
if (!base) {
|
|
||||||
|
if (!base)
|
||||||
base = 8;
|
base = 8;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!base) {
|
if (!base)
|
||||||
base = 10;
|
base = 10;
|
||||||
}
|
|
||||||
while (isxdigit (*cp) && (value = isdigit (*cp)
|
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp - '0'
|
||||||
? *cp - '0'
|
|
||||||
: (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
|
: (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
|
||||||
result = result * base + value;
|
result = result * base + value;
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endp)
|
if (endp)
|
||||||
*endp = (char *) cp;
|
*endp = (char *) cp;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +167,7 @@ static int skip_atoi(const char **s)
|
||||||
|
|
||||||
while (is_digit(**s))
|
while (is_digit(**s))
|
||||||
i = i * 10 + *((*s)++) - '0';
|
i = i * 10 + *((*s)++) - '0';
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +296,7 @@ static char *number(char *buf, char *end, unsigned NUM_TYPE num,
|
||||||
int base, int size, int precision, int type)
|
int base, int size, int precision, int type)
|
||||||
{
|
{
|
||||||
/* we are called with base 8, 10 or 16, only, thus don't need "G..." */
|
/* we are called with base 8, 10 or 16, only, thus don't need "G..." */
|
||||||
static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */
|
static const char digits[16] = "0123456789ABCDEF";
|
||||||
|
|
||||||
char tmp[66];
|
char tmp[66];
|
||||||
char sign;
|
char sign;
|
||||||
|
@ -331,9 +341,13 @@ static char *number(char *buf, char *end, unsigned NUM_TYPE num,
|
||||||
else if (base != 10) { /* 8 or 16 */
|
else if (base != 10) { /* 8 or 16 */
|
||||||
int mask = base - 1;
|
int mask = base - 1;
|
||||||
int shift = 3;
|
int shift = 3;
|
||||||
if (base == 16) shift = 4;
|
|
||||||
|
if (base == 16)
|
||||||
|
shift = 4;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
tmp[i++] = (digits[((unsigned char)num) & mask] | locase);
|
tmp[i++] = (digits[((unsigned char)num) & mask]
|
||||||
|
| locase);
|
||||||
num >>= shift;
|
num >>= shift;
|
||||||
} while (num);
|
} while (num);
|
||||||
} else { /* base 10 */
|
} else { /* base 10 */
|
||||||
|
@ -401,7 +415,8 @@ static char *string(char *buf, char *end, char *s, int field_width,
|
||||||
static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,
|
static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,
|
||||||
int precision, int flags)
|
int precision, int flags)
|
||||||
{
|
{
|
||||||
char mac_addr[6 * 3]; /* (6 * 2 hex digits), 5 colons and trailing zero */
|
/* (6 * 2 hex digits), 5 colons and trailing zero */
|
||||||
|
char mac_addr[6 * 3];
|
||||||
char *p = mac_addr;
|
char *p = mac_addr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -419,7 +434,8 @@ static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,
|
||||||
static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width,
|
static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width,
|
||||||
int precision, int flags)
|
int precision, int flags)
|
||||||
{
|
{
|
||||||
char ip6_addr[8 * 5]; /* (8 * 4 hex digits), 7 colons and trailing zero */
|
/* (8 * 4 hex digits), 7 colons and trailing zero */
|
||||||
|
char ip6_addr[8 * 5];
|
||||||
char *p = ip6_addr;
|
char *p = ip6_addr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -438,7 +454,8 @@ static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width,
|
||||||
static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
|
static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
|
||||||
int precision, int flags)
|
int precision, int flags)
|
||||||
{
|
{
|
||||||
char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */
|
/* (4 * 3 decimal digits), 3 dots and trailing zero */
|
||||||
|
char ip4_addr[4 * 4];
|
||||||
char temp[3]; /* hold each IP quad in reverse order */
|
char temp[3]; /* hold each IP quad in reverse order */
|
||||||
char *p = ip4_addr;
|
char *p = ip4_addr;
|
||||||
int i, digits;
|
int i, digits;
|
||||||
|
@ -552,11 +569,21 @@ static int vsnprintf_internal(char *buf, size_t size, const char *fmt,
|
||||||
repeat:
|
repeat:
|
||||||
++fmt; /* this also skips first '%' */
|
++fmt; /* this also skips first '%' */
|
||||||
switch (*fmt) {
|
switch (*fmt) {
|
||||||
case '-': flags |= LEFT; goto repeat;
|
case '-':
|
||||||
case '+': flags |= PLUS; goto repeat;
|
flags |= LEFT;
|
||||||
case ' ': flags |= SPACE; goto repeat;
|
goto repeat;
|
||||||
case '#': flags |= SPECIAL; goto repeat;
|
case '+':
|
||||||
case '0': flags |= ZEROPAD; goto repeat;
|
flags |= PLUS;
|
||||||
|
goto repeat;
|
||||||
|
case ' ':
|
||||||
|
flags |= SPACE;
|
||||||
|
goto repeat;
|
||||||
|
case '#':
|
||||||
|
flags |= SPECIAL;
|
||||||
|
goto repeat;
|
||||||
|
case '0':
|
||||||
|
flags |= ZEROPAD;
|
||||||
|
goto repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get field width */
|
/* get field width */
|
||||||
|
|
Loading…
Add table
Reference in a new issue