aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Goddard Rosa <andre.goddard@gmail.com>2009-12-14 21:01:06 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:32 -0500
commite7d2860b690d4f3bed6824757c540579638e3d1e (patch)
tree84268ee28893256fd6a6a7e1d4474f61dbee74e7
parent84c95c9acf088c99d8793d78036b67faa5d0b851 (diff)
tree-wide: convert open calls to remove spaces to skip_spaces() lib function
Makes use of skip_spaces() defined in lib/string.c for removing leading spaces from strings all over the tree. It decreases lib.a code size by 47 bytes and reuses the function tree-wide: text data bss dec hex filename 64688 584 592 65864 10148 (TOTALS-BEFORE) 64641 584 592 65817 10119 (TOTALS-AFTER) Also, while at it, if we see (*str && isspace(*str)), we can be sure to remove the first condition (*str) as the second one (isspace(*str)) also evaluates to 0 whenever *str == 0, making it redundant. In other words, "a char equals zero is never a space". Julia Lawall tried the semantic patch (http://coccinelle.lip6.fr) below, and found occurrences of this pattern on 3 more files: drivers/leds/led-class.c drivers/leds/ledtrig-timer.c drivers/video/output.c @@ expression str; @@ ( // ignore skip_spaces cases while (*str && isspace(*str)) { \(str++;\|++str;\) } | - *str && isspace(*str) ) Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Cc: Julia Lawall <julia@diku.dk> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Jeff Dike <jdike@addtoit.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Neil Brown <neilb@suse.de> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Cc: David Howells <dhowells@redhat.com> Cc: <linux-ext4@vger.kernel.org> Cc: Samuel Ortiz <samuel@sortiz.org> Cc: Patrick McHardy <kaber@trash.net> Cc: Takashi Iwai <tiwai@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/s390/kernel/debug.c3
-rw-r--r--arch/um/drivers/mconsole_kern.c16
-rw-r--r--arch/x86/kernel/cpu/mtrr/if.c11
-rw-r--r--drivers/leds/led-class.c2
-rw-r--r--drivers/leds/ledtrig-timer.c4
-rw-r--r--drivers/md/dm-table.c6
-rw-r--r--drivers/md/md.c4
-rw-r--r--drivers/parisc/pdc_stable.c9
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c7
-rw-r--r--drivers/pnp/interface.c36
-rw-r--r--drivers/s390/block/dasd_proc.c5
-rw-r--r--drivers/video/backlight/lcd.c4
-rw-r--r--drivers/video/display/display-sysfs.c2
-rw-r--r--drivers/video/output.c2
-rw-r--r--fs/cachefiles/daemon.c4
-rw-r--r--fs/ext4/super.c7
-rw-r--r--kernel/params.c8
-rw-r--r--lib/argv_split.c13
-rw-r--r--lib/dynamic_debug.c4
-rw-r--r--lib/vsprintf.c15
-rw-r--r--net/irda/irnet/irnet.h1
-rw-r--r--net/irda/irnet/irnet_ppp.c8
-rw-r--r--net/netfilter/xt_recent.c3
-rw-r--r--sound/pci/hda/hda_hwdep.c7
24 files changed, 66 insertions, 115 deletions
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 071c81f179ef..0168472b2fdf 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -18,6 +18,7 @@
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/ctype.h> 20#include <linux/ctype.h>
21#include <linux/string.h>
21#include <linux/sysctl.h> 22#include <linux/sysctl.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#include <linux/module.h> 24#include <linux/module.h>
@@ -1178,7 +1179,7 @@ debug_get_uint(char *buf)
1178{ 1179{
1179 int rc; 1180 int rc;
1180 1181
1181 for(; isspace(*buf); buf++); 1182 buf = skip_spaces(buf);
1182 rc = simple_strtoul(buf, &buf, 10); 1183 rc = simple_strtoul(buf, &buf, 10);
1183 if(*buf){ 1184 if(*buf){
1184 rc = -EINVAL; 1185 rc = -EINVAL;
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index f0fa47f10e6c..51069245b79a 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -6,6 +6,7 @@
6 6
7#include <linux/console.h> 7#include <linux/console.h>
8#include <linux/ctype.h> 8#include <linux/ctype.h>
9#include <linux/string.h>
9#include <linux/interrupt.h> 10#include <linux/interrupt.h>
10#include <linux/list.h> 11#include <linux/list.h>
11#include <linux/mm.h> 12#include <linux/mm.h>
@@ -131,7 +132,7 @@ void mconsole_proc(struct mc_request *req)
131 char *ptr = req->request.data, *buf; 132 char *ptr = req->request.data, *buf;
132 133
133 ptr += strlen("proc"); 134 ptr += strlen("proc");
134 while (isspace(*ptr)) ptr++; 135 ptr = skip_spaces(ptr);
135 136
136 proc = get_fs_type("proc"); 137 proc = get_fs_type("proc");
137 if (proc == NULL) { 138 if (proc == NULL) {
@@ -212,8 +213,7 @@ void mconsole_proc(struct mc_request *req)
212 char *ptr = req->request.data; 213 char *ptr = req->request.data;
213 214
214 ptr += strlen("proc"); 215 ptr += strlen("proc");
215 while (isspace(*ptr)) 216 ptr = skip_spaces(ptr);
216 ptr++;
217 snprintf(path, sizeof(path), "/proc/%s", ptr); 217 snprintf(path, sizeof(path), "/proc/%s", ptr);
218 218
219 fd = sys_open(path, 0, 0); 219 fd = sys_open(path, 0, 0);
@@ -560,8 +560,7 @@ void mconsole_config(struct mc_request *req)
560 int err; 560 int err;
561 561
562 ptr += strlen("config"); 562 ptr += strlen("config");
563 while (isspace(*ptr)) 563 ptr = skip_spaces(ptr);
564 ptr++;
565 dev = mconsole_find_dev(ptr); 564 dev = mconsole_find_dev(ptr);
566 if (dev == NULL) { 565 if (dev == NULL) {
567 mconsole_reply(req, "Bad configuration option", 1, 0); 566 mconsole_reply(req, "Bad configuration option", 1, 0);
@@ -588,7 +587,7 @@ void mconsole_remove(struct mc_request *req)
588 int err, start, end, n; 587 int err, start, end, n;
589 588
590 ptr += strlen("remove"); 589 ptr += strlen("remove");
591 while (isspace(*ptr)) ptr++; 590 ptr = skip_spaces(ptr);
592 dev = mconsole_find_dev(ptr); 591 dev = mconsole_find_dev(ptr);
593 if (dev == NULL) { 592 if (dev == NULL) {
594 mconsole_reply(req, "Bad remove option", 1, 0); 593 mconsole_reply(req, "Bad remove option", 1, 0);
@@ -712,7 +711,7 @@ void mconsole_sysrq(struct mc_request *req)
712 char *ptr = req->request.data; 711 char *ptr = req->request.data;
713 712
714 ptr += strlen("sysrq"); 713 ptr += strlen("sysrq");
715 while (isspace(*ptr)) ptr++; 714 ptr = skip_spaces(ptr);
716 715
717 /* 716 /*
718 * With 'b', the system will shut down without a chance to reply, 717 * With 'b', the system will shut down without a chance to reply,
@@ -757,8 +756,7 @@ void mconsole_stack(struct mc_request *req)
757 */ 756 */
758 757
759 ptr += strlen("stack"); 758 ptr += strlen("stack");
760 while (isspace(*ptr)) 759 ptr = skip_spaces(ptr);
761 ptr++;
762 760
763 /* 761 /*
764 * Should really check for multiple pids or reject bad args here 762 * Should really check for multiple pids or reject bad args here
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index 3c1b12d461d1..e006e56f699c 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -4,6 +4,7 @@
4#include <linux/proc_fs.h> 4#include <linux/proc_fs.h>
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/ctype.h> 6#include <linux/ctype.h>
7#include <linux/string.h>
7#include <linux/init.h> 8#include <linux/init.h>
8 9
9#define LINE_SIZE 80 10#define LINE_SIZE 80
@@ -133,8 +134,7 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
133 return -EINVAL; 134 return -EINVAL;
134 135
135 base = simple_strtoull(line + 5, &ptr, 0); 136 base = simple_strtoull(line + 5, &ptr, 0);
136 while (isspace(*ptr)) 137 ptr = skip_spaces(ptr);
137 ptr++;
138 138
139 if (strncmp(ptr, "size=", 5)) 139 if (strncmp(ptr, "size=", 5))
140 return -EINVAL; 140 return -EINVAL;
@@ -142,14 +142,11 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
142 size = simple_strtoull(ptr + 5, &ptr, 0); 142 size = simple_strtoull(ptr + 5, &ptr, 0);
143 if ((base & 0xfff) || (size & 0xfff)) 143 if ((base & 0xfff) || (size & 0xfff))
144 return -EINVAL; 144 return -EINVAL;
145 while (isspace(*ptr)) 145 ptr = skip_spaces(ptr);
146 ptr++;
147 146
148 if (strncmp(ptr, "type=", 5)) 147 if (strncmp(ptr, "type=", 5))
149 return -EINVAL; 148 return -EINVAL;
150 ptr += 5; 149 ptr = skip_spaces(ptr + 5);
151 while (isspace(*ptr))
152 ptr++;
153 150
154 for (i = 0; i < MTRR_NUM_TYPES; ++i) { 151 for (i = 0; i < MTRR_NUM_TYPES; ++i) {
155 if (strcmp(ptr, mtrr_strings[i])) 152 if (strcmp(ptr, mtrr_strings[i]))
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index f2cc13d76810..782f95822eab 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -50,7 +50,7 @@ static ssize_t led_brightness_store(struct device *dev,
50 unsigned long state = simple_strtoul(buf, &after, 10); 50 unsigned long state = simple_strtoul(buf, &after, 10);
51 size_t count = after - buf; 51 size_t count = after - buf;
52 52
53 if (*after && isspace(*after)) 53 if (isspace(*after))
54 count++; 54 count++;
55 55
56 if (count == size) { 56 if (count == size) {
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 3b83406de752..38b3378be442 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -83,7 +83,7 @@ static ssize_t led_delay_on_store(struct device *dev,
83 unsigned long state = simple_strtoul(buf, &after, 10); 83 unsigned long state = simple_strtoul(buf, &after, 10);
84 size_t count = after - buf; 84 size_t count = after - buf;
85 85
86 if (*after && isspace(*after)) 86 if (isspace(*after))
87 count++; 87 count++;
88 88
89 if (count == size) { 89 if (count == size) {
@@ -127,7 +127,7 @@ static ssize_t led_delay_off_store(struct device *dev,
127 unsigned long state = simple_strtoul(buf, &after, 10); 127 unsigned long state = simple_strtoul(buf, &after, 10);
128 size_t count = after - buf; 128 size_t count = after - buf;
129 129
130 if (*after && isspace(*after)) 130 if (isspace(*after))
131 count++; 131 count++;
132 132
133 if (count == size) { 133 if (count == size) {
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 1a6cb3c7822e..91976e8fae5f 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -12,6 +12,7 @@
12#include <linux/blkdev.h> 12#include <linux/blkdev.h>
13#include <linux/namei.h> 13#include <linux/namei.h>
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/string.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
16#include <linux/interrupt.h> 17#include <linux/interrupt.h>
17#include <linux/mutex.h> 18#include <linux/mutex.h>
@@ -600,11 +601,8 @@ int dm_split_args(int *argc, char ***argvp, char *input)
600 return -ENOMEM; 601 return -ENOMEM;
601 602
602 while (1) { 603 while (1) {
603 start = end;
604
605 /* Skip whitespace */ 604 /* Skip whitespace */
606 while (*start && isspace(*start)) 605 start = skip_spaces(end);
607 start++;
608 606
609 if (!*start) 607 if (!*start)
610 break; /* success, we hit the end */ 608 break; /* success, we hit the end */
diff --git a/drivers/md/md.c b/drivers/md/md.c
index e1f3c1715cca..6f9148623a4d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -39,6 +39,7 @@
39#include <linux/buffer_head.h> /* for invalidate_bdev */ 39#include <linux/buffer_head.h> /* for invalidate_bdev */
40#include <linux/poll.h> 40#include <linux/poll.h>
41#include <linux/ctype.h> 41#include <linux/ctype.h>
42#include <linux/string.h>
42#include <linux/hdreg.h> 43#include <linux/hdreg.h>
43#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
44#include <linux/random.h> 45#include <linux/random.h>
@@ -3439,8 +3440,7 @@ bitmap_store(mddev_t *mddev, const char *buf, size_t len)
3439 } 3440 }
3440 if (*end && !isspace(*end)) break; 3441 if (*end && !isspace(*end)) break;
3441 bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk); 3442 bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk);
3442 buf = end; 3443 buf = skip_spaces(end);
3443 while (isspace(*buf)) buf++;
3444 } 3444 }
3445 bitmap_unplug(mddev->bitmap); /* flush the bits to disk */ 3445 bitmap_unplug(mddev->bitmap); /* flush the bits to disk */
3446out: 3446out:
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 13a64bc081b6..0bc5d474b168 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -779,12 +779,9 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
779 read_unlock(&pathentry->rw_lock); 779 read_unlock(&pathentry->rw_lock);
780 780
781 DPRINTK("%s: flags before: 0x%X\n", __func__, flags); 781 DPRINTK("%s: flags before: 0x%X\n", __func__, flags);
782 782
783 temp = in; 783 temp = skip_spaces(in);
784 784
785 while (*temp && isspace(*temp))
786 temp++;
787
788 c = *temp++ - '0'; 785 c = *temp++ - '0';
789 if ((c != 0) && (c != 1)) 786 if ((c != 0) && (c != 1))
790 goto parse_error; 787 goto parse_error;
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 0ed84806f8ae..cf61d6a8ef6f 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1006,11 +1006,8 @@ static int parse_strtoul(const char *buf,
1006{ 1006{
1007 char *endp; 1007 char *endp;
1008 1008
1009 while (*buf && isspace(*buf)) 1009 *value = simple_strtoul(skip_spaces(buf), &endp, 0);
1010 buf++; 1010 endp = skip_spaces(endp);
1011 *value = simple_strtoul(buf, &endp, 0);
1012 while (*endp && isspace(*endp))
1013 endp++;
1014 if (*endp || *value > max) 1011 if (*endp || *value > max)
1015 return -EINVAL; 1012 return -EINVAL;
1016 1013
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index c3f1c8e9d254..68b0c04987e4 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -310,8 +310,7 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
310 goto done; 310 goto done;
311 } 311 }
312 312
313 while (isspace(*buf)) 313 buf = skip_spaces(buf);
314 ++buf;
315 if (!strnicmp(buf, "disable", 7)) { 314 if (!strnicmp(buf, "disable", 7)) {
316 retval = pnp_disable_dev(dev); 315 retval = pnp_disable_dev(dev);
317 goto done; 316 goto done;
@@ -353,19 +352,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
353 pnp_init_resources(dev); 352 pnp_init_resources(dev);
354 mutex_lock(&pnp_res_mutex); 353 mutex_lock(&pnp_res_mutex);
355 while (1) { 354 while (1) {
356 while (isspace(*buf)) 355 buf = skip_spaces(buf);
357 ++buf;
358 if (!strnicmp(buf, "io", 2)) { 356 if (!strnicmp(buf, "io", 2)) {
359 buf += 2; 357 buf = skip_spaces(buf + 2);
360 while (isspace(*buf))
361 ++buf;
362 start = simple_strtoul(buf, &buf, 0); 358 start = simple_strtoul(buf, &buf, 0);
363 while (isspace(*buf)) 359 buf = skip_spaces(buf);
364 ++buf;
365 if (*buf == '-') { 360 if (*buf == '-') {
366 buf += 1; 361 buf = skip_spaces(buf + 1);
367 while (isspace(*buf))
368 ++buf;
369 end = simple_strtoul(buf, &buf, 0); 362 end = simple_strtoul(buf, &buf, 0);
370 } else 363 } else
371 end = start; 364 end = start;
@@ -373,16 +366,11 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
373 continue; 366 continue;
374 } 367 }
375 if (!strnicmp(buf, "mem", 3)) { 368 if (!strnicmp(buf, "mem", 3)) {
376 buf += 3; 369 buf = skip_spaces(buf + 3);
377 while (isspace(*buf))
378 ++buf;
379 start = simple_strtoul(buf, &buf, 0); 370 start = simple_strtoul(buf, &buf, 0);
380 while (isspace(*buf)) 371 buf = skip_spaces(buf);
381 ++buf;
382 if (*buf == '-') { 372 if (*buf == '-') {
383 buf += 1; 373 buf = skip_spaces(buf + 1);
384 while (isspace(*buf))
385 ++buf;
386 end = simple_strtoul(buf, &buf, 0); 374 end = simple_strtoul(buf, &buf, 0);
387 } else 375 } else
388 end = start; 376 end = start;
@@ -390,17 +378,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
390 continue; 378 continue;
391 } 379 }
392 if (!strnicmp(buf, "irq", 3)) { 380 if (!strnicmp(buf, "irq", 3)) {
393 buf += 3; 381 buf = skip_spaces(buf + 3);
394 while (isspace(*buf))
395 ++buf;
396 start = simple_strtoul(buf, &buf, 0); 382 start = simple_strtoul(buf, &buf, 0);
397 pnp_add_irq_resource(dev, start, 0); 383 pnp_add_irq_resource(dev, start, 0);
398 continue; 384 continue;
399 } 385 }
400 if (!strnicmp(buf, "dma", 3)) { 386 if (!strnicmp(buf, "dma", 3)) {
401 buf += 3; 387 buf = skip_spaces(buf + 3);
402 while (isspace(*buf))
403 ++buf;
404 start = simple_strtoul(buf, &buf, 0); 388 start = simple_strtoul(buf, &buf, 0);
405 pnp_add_dma_resource(dev, start, 0); 389 pnp_add_dma_resource(dev, start, 0);
406 continue; 390 continue;
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 5f23eca82804..6315fbd8e68b 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -14,6 +14,7 @@
14#define KMSG_COMPONENT "dasd" 14#define KMSG_COMPONENT "dasd"
15 15
16#include <linux/ctype.h> 16#include <linux/ctype.h>
17#include <linux/string.h>
17#include <linux/seq_file.h> 18#include <linux/seq_file.h>
18#include <linux/vmalloc.h> 19#include <linux/vmalloc.h>
19#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
@@ -272,10 +273,10 @@ dasd_statistics_write(struct file *file, const char __user *user_buf,
272 DBF_EVENT(DBF_DEBUG, "/proc/dasd/statictics: '%s'\n", buffer); 273 DBF_EVENT(DBF_DEBUG, "/proc/dasd/statictics: '%s'\n", buffer);
273 274
274 /* check for valid verbs */ 275 /* check for valid verbs */
275 for (str = buffer; isspace(*str); str++); 276 str = skip_spaces(buffer);
276 if (strncmp(str, "set", 3) == 0 && isspace(str[3])) { 277 if (strncmp(str, "set", 3) == 0 && isspace(str[3])) {
277 /* 'set xxx' was given */ 278 /* 'set xxx' was given */
278 for (str = str + 4; isspace(*str); str++); 279 str = skip_spaces(str + 4);
279 if (strcmp(str, "on") == 0) { 280 if (strcmp(str, "on") == 0) {
280 /* switch on statistics profiling */ 281 /* switch on statistics profiling */
281 dasd_profile_level = DASD_PROFILE_ON; 282 dasd_profile_level = DASD_PROFILE_ON;
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index a482dd7b0311..9b3be74cee5a 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -101,7 +101,7 @@ static ssize_t lcd_store_power(struct device *dev,
101 int power = simple_strtoul(buf, &endp, 0); 101 int power = simple_strtoul(buf, &endp, 0);
102 size_t size = endp - buf; 102 size_t size = endp - buf;
103 103
104 if (*endp && isspace(*endp)) 104 if (isspace(*endp))
105 size++; 105 size++;
106 if (size != count) 106 if (size != count)
107 return -EINVAL; 107 return -EINVAL;
@@ -140,7 +140,7 @@ static ssize_t lcd_store_contrast(struct device *dev,
140 int contrast = simple_strtoul(buf, &endp, 0); 140 int contrast = simple_strtoul(buf, &endp, 0);
141 size_t size = endp - buf; 141 size_t size = endp - buf;
142 142
143 if (*endp && isspace(*endp)) 143 if (isspace(*endp))
144 size++; 144 size++;
145 if (size != count) 145 if (size != count)
146 return -EINVAL; 146 return -EINVAL;
diff --git a/drivers/video/display/display-sysfs.c b/drivers/video/display/display-sysfs.c
index 4830b1bf51e5..80abbf323b99 100644
--- a/drivers/video/display/display-sysfs.c
+++ b/drivers/video/display/display-sysfs.c
@@ -67,7 +67,7 @@ static ssize_t display_store_contrast(struct device *dev,
67 contrast = simple_strtoul(buf, &endp, 0); 67 contrast = simple_strtoul(buf, &endp, 0);
68 size = endp - buf; 68 size = endp - buf;
69 69
70 if (*endp && isspace(*endp)) 70 if (isspace(*endp))
71 size++; 71 size++;
72 72
73 if (size != count) 73 if (size != count)
diff --git a/drivers/video/output.c b/drivers/video/output.c
index 5e6439ae7394..5137aa016b83 100644
--- a/drivers/video/output.c
+++ b/drivers/video/output.c
@@ -50,7 +50,7 @@ static ssize_t video_output_store_state(struct device *dev,
50 int request_state = simple_strtoul(buf,&endp,0); 50 int request_state = simple_strtoul(buf,&endp,0);
51 size_t size = endp - buf; 51 size_t size = endp - buf;
52 52
53 if (*endp && isspace(*endp)) 53 if (isspace(*endp))
54 size++; 54 size++;
55 if (size != count) 55 if (size != count)
56 return -EINVAL; 56 return -EINVAL;
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 4618516dd994..c2413561ea75 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -21,6 +21,7 @@
21#include <linux/mount.h> 21#include <linux/mount.h>
22#include <linux/statfs.h> 22#include <linux/statfs.h>
23#include <linux/ctype.h> 23#include <linux/ctype.h>
24#include <linux/string.h>
24#include <linux/fs_struct.h> 25#include <linux/fs_struct.h>
25#include "internal.h" 26#include "internal.h"
26 27
@@ -257,8 +258,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
257 if (args == data) 258 if (args == data)
258 goto error; 259 goto error;
259 *args = '\0'; 260 *args = '\0';
260 for (args++; isspace(*args); args++) 261 args = skip_spaces(++args);
261 continue;
262 } 262 }
263 263
264 /* run the appropriate command handler */ 264 /* run the appropriate command handler */
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 768c111a77ec..827bde1f2594 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2137,11 +2137,8 @@ static int parse_strtoul(const char *buf,
2137{ 2137{
2138 char *endp; 2138 char *endp;
2139 2139
2140 while (*buf && isspace(*buf)) 2140 *value = simple_strtoul(skip_spaces(buf), &endp, 0);
2141 buf++; 2141 endp = skip_spaces(endp);
2142 *value = simple_strtoul(buf, &endp, 0);
2143 while (*endp && isspace(*endp))
2144 endp++;
2145 if (*endp || *value > max) 2142 if (*endp || *value > max)
2146 return -EINVAL; 2143 return -EINVAL;
2147 2144
diff --git a/kernel/params.c b/kernel/params.c
index d656c276508d..cf1b69183127 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -24,6 +24,7 @@
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/ctype.h> 26#include <linux/ctype.h>
27#include <linux/string.h>
27 28
28#if 0 29#if 0
29#define DEBUGP printk 30#define DEBUGP printk
@@ -122,9 +123,7 @@ static char *next_arg(char *args, char **param, char **val)
122 next = args + i; 123 next = args + i;
123 124
124 /* Chew up trailing spaces. */ 125 /* Chew up trailing spaces. */
125 while (isspace(*next)) 126 return skip_spaces(next);
126 next++;
127 return next;
128} 127}
129 128
130/* Args looks like "foo=bar,bar2 baz=fuz wiz". */ 129/* Args looks like "foo=bar,bar2 baz=fuz wiz". */
@@ -139,8 +138,7 @@ int parse_args(const char *name,
139 DEBUGP("Parsing ARGS: %s\n", args); 138 DEBUGP("Parsing ARGS: %s\n", args);
140 139
141 /* Chew leading spaces */ 140 /* Chew leading spaces */
142 while (isspace(*args)) 141 args = skip_spaces(args);
143 args++;
144 142
145 while (*args) { 143 while (*args) {
146 int ret; 144 int ret;
diff --git a/lib/argv_split.c b/lib/argv_split.c
index 5205a8dae5bc..4b1b083f219c 100644
--- a/lib/argv_split.c
+++ b/lib/argv_split.c
@@ -4,17 +4,10 @@
4 4
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/ctype.h> 6#include <linux/ctype.h>
7#include <linux/string.h>
7#include <linux/slab.h> 8#include <linux/slab.h>
8#include <linux/module.h> 9#include <linux/module.h>
9 10
10static const char *skip_sep(const char *cp)
11{
12 while (*cp && isspace(*cp))
13 cp++;
14
15 return cp;
16}
17
18static const char *skip_arg(const char *cp) 11static const char *skip_arg(const char *cp)
19{ 12{
20 while (*cp && !isspace(*cp)) 13 while (*cp && !isspace(*cp))
@@ -28,7 +21,7 @@ static int count_argc(const char *str)
28 int count = 0; 21 int count = 0;
29 22
30 while (*str) { 23 while (*str) {
31 str = skip_sep(str); 24 str = skip_spaces(str);
32 if (*str) { 25 if (*str) {
33 count++; 26 count++;
34 str = skip_arg(str); 27 str = skip_arg(str);
@@ -82,7 +75,7 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp)
82 argvp = argv; 75 argvp = argv;
83 76
84 while (*str) { 77 while (*str) {
85 str = skip_sep(str); 78 str = skip_spaces(str);
86 79
87 if (*str) { 80 if (*str) {
88 const char *p = str; 81 const char *p = str;
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index e22c148e4b7f..f93502915988 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -21,6 +21,7 @@
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/sysctl.h> 22#include <linux/sysctl.h>
23#include <linux/ctype.h> 23#include <linux/ctype.h>
24#include <linux/string.h>
24#include <linux/uaccess.h> 25#include <linux/uaccess.h>
25#include <linux/dynamic_debug.h> 26#include <linux/dynamic_debug.h>
26#include <linux/debugfs.h> 27#include <linux/debugfs.h>
@@ -209,8 +210,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
209 char *end; 210 char *end;
210 211
211 /* Skip leading whitespace */ 212 /* Skip leading whitespace */
212 while (*buf && isspace(*buf)) 213 buf = skip_spaces(buf);
213 buf++;
214 if (!*buf) 214 if (!*buf)
215 break; /* oh, it was trailing whitespace */ 215 break; /* oh, it was trailing whitespace */
216 216
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c50733a690f0..7857d4dd62d3 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1766,13 +1766,6 @@ EXPORT_SYMBOL_GPL(bprintf);
1766 1766
1767#endif /* CONFIG_BINARY_PRINTF */ 1767#endif /* CONFIG_BINARY_PRINTF */
1768 1768
1769static noinline char *skip_space(const char *str)
1770{
1771 while (isspace(*str))
1772 ++str;
1773 return (char *)str;
1774}
1775
1776/** 1769/**
1777 * vsscanf - Unformat a buffer into a list of arguments 1770 * vsscanf - Unformat a buffer into a list of arguments
1778 * @buf: input buffer 1771 * @buf: input buffer
@@ -1794,8 +1787,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
1794 * white space, including none, in the input. 1787 * white space, including none, in the input.
1795 */ 1788 */
1796 if (isspace(*fmt)) { 1789 if (isspace(*fmt)) {
1797 fmt = skip_space(fmt); 1790 fmt = skip_spaces(++fmt);
1798 str = skip_space(str); 1791 str = skip_spaces(str);
1799 } 1792 }
1800 1793
1801 /* anything that is not a conversion must match exactly */ 1794 /* anything that is not a conversion must match exactly */
@@ -1865,7 +1858,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
1865 if (field_width == -1) 1858 if (field_width == -1)
1866 field_width = INT_MAX; 1859 field_width = INT_MAX;
1867 /* first, skip leading white space in buffer */ 1860 /* first, skip leading white space in buffer */
1868 str = skip_space(str); 1861 str = skip_spaces(str);
1869 1862
1870 /* now copy until next white space */ 1863 /* now copy until next white space */
1871 while (*str && !isspace(*str) && field_width--) 1864 while (*str && !isspace(*str) && field_width--)
@@ -1907,7 +1900,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
1907 /* have some sort of integer conversion. 1900 /* have some sort of integer conversion.
1908 * first, skip white space in buffer. 1901 * first, skip white space in buffer.
1909 */ 1902 */
1910 str = skip_space(str); 1903 str = skip_spaces(str);
1911 1904
1912 digit = *str; 1905 digit = *str;
1913 if (is_sign && digit == '-') 1906 if (is_sign && digit == '-')
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h
index b001c361ad30..4300df35d37d 100644
--- a/net/irda/irnet/irnet.h
+++ b/net/irda/irnet/irnet.h
@@ -249,6 +249,7 @@
249#include <linux/poll.h> 249#include <linux/poll.h>
250#include <linux/capability.h> 250#include <linux/capability.h>
251#include <linux/ctype.h> /* isspace() */ 251#include <linux/ctype.h> /* isspace() */
252#include <linux/string.h> /* skip_spaces() */
252#include <asm/uaccess.h> 253#include <asm/uaccess.h>
253#include <linux/init.h> 254#include <linux/init.h>
254 255
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c
index 7dea882dbb75..156020d138b5 100644
--- a/net/irda/irnet/irnet_ppp.c
+++ b/net/irda/irnet/irnet_ppp.c
@@ -76,9 +76,8 @@ irnet_ctrl_write(irnet_socket * ap,
76 /* Look at the next command */ 76 /* Look at the next command */
77 start = next; 77 start = next;
78 78
79 /* Scrap whitespaces before the command */ 79 /* Scrap whitespaces before the command */
80 while(isspace(*start)) 80 start = skip_spaces(start);
81 start++;
82 81
83 /* ',' is our command separator */ 82 /* ',' is our command separator */
84 next = strchr(start, ','); 83 next = strchr(start, ',');
@@ -133,8 +132,7 @@ irnet_ctrl_write(irnet_socket * ap,
133 char * endp; 132 char * endp;
134 133
135 /* Scrap whitespaces before the command */ 134 /* Scrap whitespaces before the command */
136 while(isspace(*begp)) 135 begp = skip_spaces(begp);
137 begp++;
138 136
139 /* Convert argument to a number (last arg is the base) */ 137 /* Convert argument to a number (last arg is the base) */
140 addr = simple_strtoul(begp, &endp, 16); 138 addr = simple_strtoul(begp, &endp, 16);
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index eb0ceb846527..fc70a49c0afd 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -482,8 +482,7 @@ static ssize_t recent_old_proc_write(struct file *file,
482 if (copy_from_user(buf, input, size)) 482 if (copy_from_user(buf, input, size))
483 return -EFAULT; 483 return -EFAULT;
484 484
485 while (isspace(*c)) 485 c = skip_spaces(c);
486 c++;
487 486
488 if (size - (c - buf) < 5) 487 if (size - (c - buf) < 5)
489 return c - buf; 488 return c - buf;
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index d24328661c6a..40ccb419b6e9 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -24,6 +24,7 @@
24#include <linux/compat.h> 24#include <linux/compat.h>
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/ctype.h> 26#include <linux/ctype.h>
27#include <linux/string.h>
27#include <linux/firmware.h> 28#include <linux/firmware.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include "hda_codec.h" 30#include "hda_codec.h"
@@ -428,8 +429,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf)
428 char *key, *val; 429 char *key, *val;
429 struct hda_hint *hint; 430 struct hda_hint *hint;
430 431
431 while (isspace(*buf)) 432 buf = skip_spaces(buf);
432 buf++;
433 if (!*buf || *buf == '#' || *buf == '\n') 433 if (!*buf || *buf == '#' || *buf == '\n')
434 return 0; 434 return 0;
435 if (*buf == '=') 435 if (*buf == '=')
@@ -444,8 +444,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf)
444 return -EINVAL; 444 return -EINVAL;
445 } 445 }
446 *val++ = 0; 446 *val++ = 0;
447 while (isspace(*val)) 447 val = skip_spaces(val);
448 val++;
449 remove_trail_spaces(key); 448 remove_trail_spaces(key);
450 remove_trail_spaces(val); 449 remove_trail_spaces(val);
451 hint = get_hint(codec, key); 450 hint = get_hint(codec, key);