X-Git-Url: https://git.stricted.de/?a=blobdiff_plain;f=lib%2Fcmdline.c;h=f5f3ad8b62ff9844739fcdedde9389e6869e0cfc;hb=264b29900657f53fb4ddc8bf08f447c4c227b2cf;hp=f596c08d213a0726c5f395209a3e20d730c3ea2c;hpb=920841d8d1d61bc12b43f95a579a5374f6d98f81;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git diff --git a/lib/cmdline.c b/lib/cmdline.c index f596c08d213a..f5f3ad8b62ff 100644 --- a/lib/cmdline.c +++ b/lib/cmdline.c @@ -116,7 +116,7 @@ char *get_options(const char *str, int nints, int *ints) /** * memparse - parse a string with mem suffixes into a number * @ptr: Where parse begins - * @retptr: (output) Pointer to next char after parse completes + * @retptr: (output) Optional pointer to next char after parse completes * * Parses a string into a number. The number stored at @ptr is * potentially suffixed with %K (for kilobytes, or 1024 bytes), @@ -126,11 +126,13 @@ char *get_options(const char *str, int nints, int *ints) * megabyte, or one gigabyte, respectively. */ -unsigned long long memparse (char *ptr, char **retptr) +unsigned long long memparse(const char *ptr, char **retptr) { - unsigned long long ret = simple_strtoull (ptr, retptr, 0); + char *endptr; /* local pointer to end of parsed string */ - switch (**retptr) { + unsigned long long ret = simple_strtoull(ptr, &endptr, 0); + + switch (*endptr) { case 'G': case 'g': ret <<= 10; @@ -140,10 +142,14 @@ unsigned long long memparse (char *ptr, char **retptr) case 'K': case 'k': ret <<= 10; - (*retptr)++; + endptr++; default: break; } + + if (retptr) + *retptr = endptr; + return ret; }