diff options
author | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 01:06:28 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 01:06:28 -0500 |
commit | f43dc23d5ea91fca257be02138a255f02d98e806 (patch) | |
tree | b29722f6e965316e90ac97abf79923ced250dc21 /lib/parser.c | |
parent | f8e53553f452dcbf67cb89c8cba63a1cd6eb4cc0 (diff) | |
parent | 4162cf64973df51fc885825bc9ca4d055891c49f (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into common/serial-rework
Conflicts:
arch/sh/kernel/cpu/sh2/setup-sh7619.c
arch/sh/kernel/cpu/sh2a/setup-mxg.c
arch/sh/kernel/cpu/sh2a/setup-sh7201.c
arch/sh/kernel/cpu/sh2a/setup-sh7203.c
arch/sh/kernel/cpu/sh2a/setup-sh7206.c
arch/sh/kernel/cpu/sh3/setup-sh7705.c
arch/sh/kernel/cpu/sh3/setup-sh770x.c
arch/sh/kernel/cpu/sh3/setup-sh7710.c
arch/sh/kernel/cpu/sh3/setup-sh7720.c
arch/sh/kernel/cpu/sh4/setup-sh4-202.c
arch/sh/kernel/cpu/sh4/setup-sh7750.c
arch/sh/kernel/cpu/sh4/setup-sh7760.c
arch/sh/kernel/cpu/sh4a/setup-sh7343.c
arch/sh/kernel/cpu/sh4a/setup-sh7366.c
arch/sh/kernel/cpu/sh4a/setup-sh7722.c
arch/sh/kernel/cpu/sh4a/setup-sh7723.c
arch/sh/kernel/cpu/sh4a/setup-sh7724.c
arch/sh/kernel/cpu/sh4a/setup-sh7763.c
arch/sh/kernel/cpu/sh4a/setup-sh7770.c
arch/sh/kernel/cpu/sh4a/setup-sh7780.c
arch/sh/kernel/cpu/sh4a/setup-sh7785.c
arch/sh/kernel/cpu/sh4a/setup-sh7786.c
arch/sh/kernel/cpu/sh4a/setup-shx3.c
arch/sh/kernel/cpu/sh5/setup-sh5.c
drivers/serial/sh-sci.c
drivers/serial/sh-sci.h
include/linux/serial_sci.h
Diffstat (limited to 'lib/parser.c')
-rw-r--r-- | lib/parser.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/parser.c b/lib/parser.c index b00d02059a5..6e89eca5cca 100644 --- a/lib/parser.c +++ b/lib/parser.c | |||
@@ -56,13 +56,16 @@ static int match_one(char *s, const char *p, substring_t args[]) | |||
56 | 56 | ||
57 | args[argc].from = s; | 57 | args[argc].from = s; |
58 | switch (*p++) { | 58 | switch (*p++) { |
59 | case 's': | 59 | case 's': { |
60 | if (strlen(s) == 0) | 60 | size_t str_len = strlen(s); |
61 | |||
62 | if (str_len == 0) | ||
61 | return 0; | 63 | return 0; |
62 | else if (len == -1 || len > strlen(s)) | 64 | if (len == -1 || len > str_len) |
63 | len = strlen(s); | 65 | len = str_len; |
64 | args[argc].to = s + len; | 66 | args[argc].to = s + len; |
65 | break; | 67 | break; |
68 | } | ||
66 | case 'd': | 69 | case 'd': |
67 | simple_strtol(s, &args[argc].to, 0); | 70 | simple_strtol(s, &args[argc].to, 0); |
68 | goto num; | 71 | goto num; |
@@ -125,12 +128,13 @@ static int match_number(substring_t *s, int *result, int base) | |||
125 | char *endp; | 128 | char *endp; |
126 | char *buf; | 129 | char *buf; |
127 | int ret; | 130 | int ret; |
131 | size_t len = s->to - s->from; | ||
128 | 132 | ||
129 | buf = kmalloc(s->to - s->from + 1, GFP_KERNEL); | 133 | buf = kmalloc(len + 1, GFP_KERNEL); |
130 | if (!buf) | 134 | if (!buf) |
131 | return -ENOMEM; | 135 | return -ENOMEM; |
132 | memcpy(buf, s->from, s->to - s->from); | 136 | memcpy(buf, s->from, len); |
133 | buf[s->to - s->from] = '\0'; | 137 | buf[len] = '\0'; |
134 | *result = simple_strtol(buf, &endp, base); | 138 | *result = simple_strtol(buf, &endp, base); |
135 | ret = 0; | 139 | ret = 0; |
136 | if (endp == buf) | 140 | if (endp == buf) |