X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=lib%2Fvsprintf.c;h=533a96b85e3629a765ba807a594f8509fab9f68a;hb=e7abe919673994e8040aba0273ceb9a5b2609806;hp=dd13bca5a73d73c0924b67d7333bdc501b810eea;hpb=d266f669252a5ebd7e9b940743ec7d05cdbd4061;p=karo-tx-uboot.git diff --git a/lib/vsprintf.c b/lib/vsprintf.c index dd13bca5a7..533a96b85e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -28,7 +28,7 @@ /* some reluctance to put this into a new limits.h, so it is here */ #define INT_MAX ((int)(~0U>>1)) -const char hex_asc[] = "0123456789abcdef"; +static const char hex_asc[] = "0123456789abcdef"; #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] @@ -103,7 +103,7 @@ long simple_strtol(const char *cp, char **endp, unsigned int base) return simple_strtoul(cp, endp, base); } -int ustrtoul(const char *cp, char **endp, unsigned int base) +unsigned long ustrtoul(const char *cp, char **endp, unsigned int base) { unsigned long result = simple_strtoul(cp, endp, base); switch (**endp) { @@ -126,6 +126,29 @@ int ustrtoul(const char *cp, char **endp, unsigned int base) return result; } +unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base) +{ + unsigned long long result = simple_strtoull(cp, endp, base); + switch (**endp) { + case 'G': + result *= 1024; + /* fall through */ + case 'M': + result *= 1024; + /* fall through */ + case 'K': + case 'k': + result *= 1024; + if ((*endp)[1] == 'i') { + if ((*endp)[2] == 'B') + (*endp) += 3; + else + (*endp) += 2; + } + } + return result; +} + unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) { @@ -395,7 +418,7 @@ static char *string(char *buf, char *end, char *s, int field_width, { int len, i; - if (s == 0) + if (s == NULL) s = ""; len = strnlen(s, precision);