X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fcmdline.c;h=5ba8a942a478fe8d75f895ea7f26f876810772a5;hb=a25bdd62893909b21fd6415d76b0fa21755d5001;hp=8a5b5303bd4f7a78187b4138eb08945c6333c10c;hpb=6ee7e78e7c78d871409ad4df30551c9355be7d0e;p=pandora-kernel.git diff --git a/lib/cmdline.c b/lib/cmdline.c index 8a5b5303bd4f..5ba8a942a478 100644 --- a/lib/cmdline.c +++ b/lib/cmdline.c @@ -43,10 +43,10 @@ static int get_range(char **str, int *pint) * comma as well. * * Return values: - * 0 : no int in string - * 1 : int found, no subsequent comma - * 2 : int found including a subsequent comma - * 3 : hyphen found to denote a range + * 0 - no int in string + * 1 - int found, no subsequent comma + * 2 - int found including a subsequent comma + * 3 - hyphen found to denote a range */ int get_option (char **str, int *pint) @@ -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(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; }