Message ID | CAMRmmpLkp58en6mikZ9MAYwoA_kkrZx+UNTifjXSw3=hELLZZw@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Oct 23, 2012 at 05:11:27PM +0800, Rock Lee wrote: > Since the function atoi(l) series stop at the first non numeric chars, > > So there's no need to strdup the original s and modify s[len-1] = '\0' This change is superseded and contained in Goffredos patches which I prefer for inclusion as they do more extensive updates. thanks anyway, david -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/mkfs.c b/mkfs.c index 47f0c9c..663d73c 100644 --- a/mkfs.c +++ b/mkfs.c @@ -61,8 +61,6 @@ static u64 parse_size(char *s) u64 mult = 1; u64 ret; - s = strdup(s); - if (len && !isdigit(s[len - 1])) { c = tolower(s[len - 1]); switch (c) { @@ -78,10 +76,9 @@ static u64 parse_size(char *s) fprintf(stderr, "Unknown size descriptor %c\n", c); exit(1); } - s[len - 1] = '\0'; } + ret = atol(s) * mult; - free(s); return ret; }
Since the function atoi(l) series stop at the first non numeric chars, So there's no need to strdup the original s and modify s[len-1] = '\0' Signed-off-by: Rock Lee <zimilo@code-trick.com> --- mkfs.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)