Commit e7d2860b authored by André Goddard Rosa's avatar André Goddard Rosa Committed by Linus Torvalds

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: default avatarAndré 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 84c95c9a
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -1178,7 +1179,7 @@ debug_get_uint(char *buf) ...@@ -1178,7 +1179,7 @@ debug_get_uint(char *buf)
{ {
int rc; int rc;
for(; isspace(*buf); buf++); buf = skip_spaces(buf);
rc = simple_strtoul(buf, &buf, 10); rc = simple_strtoul(buf, &buf, 10);
if(*buf){ if(*buf){
rc = -EINVAL; rc = -EINVAL;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/console.h> #include <linux/console.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/mm.h> #include <linux/mm.h>
...@@ -131,7 +132,7 @@ void mconsole_proc(struct mc_request *req) ...@@ -131,7 +132,7 @@ void mconsole_proc(struct mc_request *req)
char *ptr = req->request.data, *buf; char *ptr = req->request.data, *buf;
ptr += strlen("proc"); ptr += strlen("proc");
while (isspace(*ptr)) ptr++; ptr = skip_spaces(ptr);
proc = get_fs_type("proc"); proc = get_fs_type("proc");
if (proc == NULL) { if (proc == NULL) {
...@@ -212,8 +213,7 @@ void mconsole_proc(struct mc_request *req) ...@@ -212,8 +213,7 @@ void mconsole_proc(struct mc_request *req)
char *ptr = req->request.data; char *ptr = req->request.data;
ptr += strlen("proc"); ptr += strlen("proc");
while (isspace(*ptr)) ptr = skip_spaces(ptr);
ptr++;
snprintf(path, sizeof(path), "/proc/%s", ptr); snprintf(path, sizeof(path), "/proc/%s", ptr);
fd = sys_open(path, 0, 0); fd = sys_open(path, 0, 0);
...@@ -560,8 +560,7 @@ void mconsole_config(struct mc_request *req) ...@@ -560,8 +560,7 @@ void mconsole_config(struct mc_request *req)
int err; int err;
ptr += strlen("config"); ptr += strlen("config");
while (isspace(*ptr)) ptr = skip_spaces(ptr);
ptr++;
dev = mconsole_find_dev(ptr); dev = mconsole_find_dev(ptr);
if (dev == NULL) { if (dev == NULL) {
mconsole_reply(req, "Bad configuration option", 1, 0); mconsole_reply(req, "Bad configuration option", 1, 0);
...@@ -588,7 +587,7 @@ void mconsole_remove(struct mc_request *req) ...@@ -588,7 +587,7 @@ void mconsole_remove(struct mc_request *req)
int err, start, end, n; int err, start, end, n;
ptr += strlen("remove"); ptr += strlen("remove");
while (isspace(*ptr)) ptr++; ptr = skip_spaces(ptr);
dev = mconsole_find_dev(ptr); dev = mconsole_find_dev(ptr);
if (dev == NULL) { if (dev == NULL) {
mconsole_reply(req, "Bad remove option", 1, 0); mconsole_reply(req, "Bad remove option", 1, 0);
...@@ -712,7 +711,7 @@ void mconsole_sysrq(struct mc_request *req) ...@@ -712,7 +711,7 @@ void mconsole_sysrq(struct mc_request *req)
char *ptr = req->request.data; char *ptr = req->request.data;
ptr += strlen("sysrq"); ptr += strlen("sysrq");
while (isspace(*ptr)) ptr++; ptr = skip_spaces(ptr);
/* /*
* With 'b', the system will shut down without a chance to reply, * With 'b', the system will shut down without a chance to reply,
...@@ -757,8 +756,7 @@ void mconsole_stack(struct mc_request *req) ...@@ -757,8 +756,7 @@ void mconsole_stack(struct mc_request *req)
*/ */
ptr += strlen("stack"); ptr += strlen("stack");
while (isspace(*ptr)) ptr = skip_spaces(ptr);
ptr++;
/* /*
* Should really check for multiple pids or reject bad args here * Should really check for multiple pids or reject bad args here
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/init.h> #include <linux/init.h>
#define LINE_SIZE 80 #define LINE_SIZE 80
...@@ -133,8 +134,7 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos) ...@@ -133,8 +134,7 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
return -EINVAL; return -EINVAL;
base = simple_strtoull(line + 5, &ptr, 0); base = simple_strtoull(line + 5, &ptr, 0);
while (isspace(*ptr)) ptr = skip_spaces(ptr);
ptr++;
if (strncmp(ptr, "size=", 5)) if (strncmp(ptr, "size=", 5))
return -EINVAL; return -EINVAL;
...@@ -142,14 +142,11 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos) ...@@ -142,14 +142,11 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
size = simple_strtoull(ptr + 5, &ptr, 0); size = simple_strtoull(ptr + 5, &ptr, 0);
if ((base & 0xfff) || (size & 0xfff)) if ((base & 0xfff) || (size & 0xfff))
return -EINVAL; return -EINVAL;
while (isspace(*ptr)) ptr = skip_spaces(ptr);
ptr++;
if (strncmp(ptr, "type=", 5)) if (strncmp(ptr, "type=", 5))
return -EINVAL; return -EINVAL;
ptr += 5; ptr = skip_spaces(ptr + 5);
while (isspace(*ptr))
ptr++;
for (i = 0; i < MTRR_NUM_TYPES; ++i) { for (i = 0; i < MTRR_NUM_TYPES; ++i) {
if (strcmp(ptr, mtrr_strings[i])) if (strcmp(ptr, mtrr_strings[i]))
......
...@@ -50,7 +50,7 @@ static ssize_t led_brightness_store(struct device *dev, ...@@ -50,7 +50,7 @@ static ssize_t led_brightness_store(struct device *dev,
unsigned long state = simple_strtoul(buf, &after, 10); unsigned long state = simple_strtoul(buf, &after, 10);
size_t count = after - buf; size_t count = after - buf;
if (*after && isspace(*after)) if (isspace(*after))
count++; count++;
if (count == size) { if (count == size) {
......
...@@ -83,7 +83,7 @@ static ssize_t led_delay_on_store(struct device *dev, ...@@ -83,7 +83,7 @@ static ssize_t led_delay_on_store(struct device *dev,
unsigned long state = simple_strtoul(buf, &after, 10); unsigned long state = simple_strtoul(buf, &after, 10);
size_t count = after - buf; size_t count = after - buf;
if (*after && isspace(*after)) if (isspace(*after))
count++; count++;
if (count == size) { if (count == size) {
...@@ -127,7 +127,7 @@ static ssize_t led_delay_off_store(struct device *dev, ...@@ -127,7 +127,7 @@ static ssize_t led_delay_off_store(struct device *dev,
unsigned long state = simple_strtoul(buf, &after, 10); unsigned long state = simple_strtoul(buf, &after, 10);
size_t count = after - buf; size_t count = after - buf;
if (*after && isspace(*after)) if (isspace(*after))
count++; count++;
if (count == size) { if (count == size) {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/mutex.h> #include <linux/mutex.h>
...@@ -600,11 +601,8 @@ int dm_split_args(int *argc, char ***argvp, char *input) ...@@ -600,11 +601,8 @@ int dm_split_args(int *argc, char ***argvp, char *input)
return -ENOMEM; return -ENOMEM;
while (1) { while (1) {
start = end;
/* Skip whitespace */ /* Skip whitespace */
while (*start && isspace(*start)) start = skip_spaces(end);
start++;
if (!*start) if (!*start)
break; /* success, we hit the end */ break; /* success, we hit the end */
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/buffer_head.h> /* for invalidate_bdev */ #include <linux/buffer_head.h> /* for invalidate_bdev */
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/random.h> #include <linux/random.h>
...@@ -3439,8 +3440,7 @@ bitmap_store(mddev_t *mddev, const char *buf, size_t len) ...@@ -3439,8 +3440,7 @@ bitmap_store(mddev_t *mddev, const char *buf, size_t len)
} }
if (*end && !isspace(*end)) break; if (*end && !isspace(*end)) break;
bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk); bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk);
buf = end; buf = skip_spaces(end);
while (isspace(*buf)) buf++;
} }
bitmap_unplug(mddev->bitmap); /* flush the bits to disk */ bitmap_unplug(mddev->bitmap); /* flush the bits to disk */
out: out:
......
...@@ -780,10 +780,7 @@ static ssize_t pdcs_auto_write(struct kobject *kobj, ...@@ -780,10 +780,7 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
DPRINTK("%s: flags before: 0x%X\n", __func__, flags); DPRINTK("%s: flags before: 0x%X\n", __func__, flags);
temp = in; temp = skip_spaces(in);
while (*temp && isspace(*temp))
temp++;
c = *temp++ - '0'; c = *temp++ - '0';
if ((c != 0) && (c != 1)) if ((c != 0) && (c != 1))
......
...@@ -1006,11 +1006,8 @@ static int parse_strtoul(const char *buf, ...@@ -1006,11 +1006,8 @@ static int parse_strtoul(const char *buf,
{ {
char *endp; char *endp;
while (*buf && isspace(*buf)) *value = simple_strtoul(skip_spaces(buf), &endp, 0);
buf++; endp = skip_spaces(endp);
*value = simple_strtoul(buf, &endp, 0);
while (*endp && isspace(*endp))
endp++;
if (*endp || *value > max) if (*endp || *value > max)
return -EINVAL; return -EINVAL;
......
...@@ -310,8 +310,7 @@ static ssize_t pnp_set_current_resources(struct device *dmdev, ...@@ -310,8 +310,7 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
goto done; goto done;
} }
while (isspace(*buf)) buf = skip_spaces(buf);
++buf;
if (!strnicmp(buf, "disable", 7)) { if (!strnicmp(buf, "disable", 7)) {
retval = pnp_disable_dev(dev); retval = pnp_disable_dev(dev);
goto done; goto done;
...@@ -353,19 +352,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev, ...@@ -353,19 +352,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
pnp_init_resources(dev); pnp_init_resources(dev);
mutex_lock(&pnp_res_mutex); mutex_lock(&pnp_res_mutex);
while (1) { while (1) {
while (isspace(*buf)) buf = skip_spaces(buf);
++buf;
if (!strnicmp(buf, "io", 2)) { if (!strnicmp(buf, "io", 2)) {
buf += 2; buf = skip_spaces(buf + 2);
while (isspace(*buf))
++buf;
start = simple_strtoul(buf, &buf, 0); start = simple_strtoul(buf, &buf, 0);
while (isspace(*buf)) buf = skip_spaces(buf);
++buf;
if (*buf == '-') { if (*buf == '-') {
buf += 1; buf = skip_spaces(buf + 1);
while (isspace(*buf))
++buf;
end = simple_strtoul(buf, &buf, 0); end = simple_strtoul(buf, &buf, 0);
} else } else
end = start; end = start;
...@@ -373,16 +366,11 @@ static ssize_t pnp_set_current_resources(struct device *dmdev, ...@@ -373,16 +366,11 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
continue; continue;
} }
if (!strnicmp(buf, "mem", 3)) { if (!strnicmp(buf, "mem", 3)) {
buf += 3; buf = skip_spaces(buf + 3);
while (isspace(*buf))
++buf;
start = simple_strtoul(buf, &buf, 0); start = simple_strtoul(buf, &buf, 0);
while (isspace(*buf)) buf = skip_spaces(buf);
++buf;
if (*buf == '-') { if (*buf == '-') {
buf += 1; buf = skip_spaces(buf + 1);
while (isspace(*buf))
++buf;
end = simple_strtoul(buf, &buf, 0); end = simple_strtoul(buf, &buf, 0);
} else } else
end = start; end = start;
...@@ -390,17 +378,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev, ...@@ -390,17 +378,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
continue; continue;
} }
if (!strnicmp(buf, "irq", 3)) { if (!strnicmp(buf, "irq", 3)) {
buf += 3; buf = skip_spaces(buf + 3);
while (isspace(*buf))
++buf;
start = simple_strtoul(buf, &buf, 0); start = simple_strtoul(buf, &buf, 0);
pnp_add_irq_resource(dev, start, 0); pnp_add_irq_resource(dev, start, 0);
continue; continue;
} }
if (!strnicmp(buf, "dma", 3)) { if (!strnicmp(buf, "dma", 3)) {
buf += 3; buf = skip_spaces(buf + 3);
while (isspace(*buf))
++buf;
start = simple_strtoul(buf, &buf, 0); start = simple_strtoul(buf, &buf, 0);
pnp_add_dma_resource(dev, start, 0); pnp_add_dma_resource(dev, start, 0);
continue; continue;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define KMSG_COMPONENT "dasd" #define KMSG_COMPONENT "dasd"
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
...@@ -272,10 +273,10 @@ dasd_statistics_write(struct file *file, const char __user *user_buf, ...@@ -272,10 +273,10 @@ dasd_statistics_write(struct file *file, const char __user *user_buf,
DBF_EVENT(DBF_DEBUG, "/proc/dasd/statictics: '%s'\n", buffer); DBF_EVENT(DBF_DEBUG, "/proc/dasd/statictics: '%s'\n", buffer);
/* check for valid verbs */ /* check for valid verbs */
for (str = buffer; isspace(*str); str++); str = skip_spaces(buffer);
if (strncmp(str, "set", 3) == 0 && isspace(str[3])) { if (strncmp(str, "set", 3) == 0 && isspace(str[3])) {
/* 'set xxx' was given */ /* 'set xxx' was given */
for (str = str + 4; isspace(*str); str++); str = skip_spaces(str + 4);
if (strcmp(str, "on") == 0) { if (strcmp(str, "on") == 0) {
/* switch on statistics profiling */ /* switch on statistics profiling */
dasd_profile_level = DASD_PROFILE_ON; dasd_profile_level = DASD_PROFILE_ON;
......
...@@ -101,7 +101,7 @@ static ssize_t lcd_store_power(struct device *dev, ...@@ -101,7 +101,7 @@ static ssize_t lcd_store_power(struct device *dev,
int power = simple_strtoul(buf, &endp, 0); int power = simple_strtoul(buf, &endp, 0);
size_t size = endp - buf; size_t size = endp - buf;
if (*endp && isspace(*endp)) if (isspace(*endp))
size++; size++;
if (size != count) if (size != count)
return -EINVAL; return -EINVAL;
...@@ -140,7 +140,7 @@ static ssize_t lcd_store_contrast(struct device *dev, ...@@ -140,7 +140,7 @@ static ssize_t lcd_store_contrast(struct device *dev,
int contrast = simple_strtoul(buf, &endp, 0); int contrast = simple_strtoul(buf, &endp, 0);
size_t size = endp - buf; size_t size = endp - buf;
if (*endp && isspace(*endp)) if (isspace(*endp))
size++; size++;
if (size != count) if (size != count)
return -EINVAL; return -EINVAL;
......
...@@ -67,7 +67,7 @@ static ssize_t display_store_contrast(struct device *dev, ...@@ -67,7 +67,7 @@ static ssize_t display_store_contrast(struct device *dev,
contrast = simple_strtoul(buf, &endp, 0); contrast = simple_strtoul(buf, &endp, 0);
size = endp - buf; size = endp - buf;
if (*endp && isspace(*endp)) if (isspace(*endp))
size++; size++;
if (size != count) if (size != count)
......
...@@ -50,7 +50,7 @@ static ssize_t video_output_store_state(struct device *dev, ...@@ -50,7 +50,7 @@ static ssize_t video_output_store_state(struct device *dev,
int request_state = simple_strtoul(buf,&endp,0); int request_state = simple_strtoul(buf,&endp,0);
size_t size = endp - buf; size_t size = endp - buf;
if (*endp && isspace(*endp)) if (isspace(*endp))
size++; size++;
if (size != count) if (size != count)
return -EINVAL; return -EINVAL;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/statfs.h> #include <linux/statfs.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/fs_struct.h> #include <linux/fs_struct.h>
#include "internal.h" #include "internal.h"
...@@ -257,8 +258,7 @@ static ssize_t cachefiles_daemon_write(struct file *file, ...@@ -257,8 +258,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
if (args == data) if (args == data)
goto error; goto error;
*args = '\0'; *args = '\0';
for (args++; isspace(*args); args++) args = skip_spaces(++args);
continue;
} }
/* run the appropriate command handler */ /* run the appropriate command handler */
......
...@@ -2137,11 +2137,8 @@ static int parse_strtoul(const char *buf, ...@@ -2137,11 +2137,8 @@ static int parse_strtoul(const char *buf,
{ {
char *endp; char *endp;
while (*buf && isspace(*buf)) *value = simple_strtoul(skip_spaces(buf), &endp, 0);
buf++; endp = skip_spaces(endp);
*value = simple_strtoul(buf, &endp, 0);
while (*endp && isspace(*endp))
endp++;
if (*endp || *value > max) if (*endp || *value > max)
return -EINVAL; return -EINVAL;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#if 0 #if 0
#define DEBUGP printk #define DEBUGP printk
...@@ -122,9 +123,7 @@ static char *next_arg(char *args, char **param, char **val) ...@@ -122,9 +123,7 @@ static char *next_arg(char *args, char **param, char **val)
next = args + i; next = args + i;
/* Chew up trailing spaces. */ /* Chew up trailing spaces. */
while (isspace(*next)) return skip_spaces(next);
next++;
return next;
} }
/* Args looks like "foo=bar,bar2 baz=fuz wiz". */ /* Args looks like "foo=bar,bar2 baz=fuz wiz". */
...@@ -139,8 +138,7 @@ int parse_args(const char *name, ...@@ -139,8 +138,7 @@ int parse_args(const char *name,
DEBUGP("Parsing ARGS: %s\n", args); DEBUGP("Parsing ARGS: %s\n", args);
/* Chew leading spaces */ /* Chew leading spaces */
while (isspace(*args)) args = skip_spaces(args);
args++;
while (*args) { while (*args) {
int ret; int ret;
......
...@@ -4,17 +4,10 @@ ...@@ -4,17 +4,10 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
static const char *skip_sep(const char *cp)
{
while (*cp && isspace(*cp))
cp++;
return cp;
}
static const char *skip_arg(const char *cp) static const char *skip_arg(const char *cp)
{ {
while (*cp && !isspace(*cp)) while (*cp && !isspace(*cp))
...@@ -28,7 +21,7 @@ static int count_argc(const char *str) ...@@ -28,7 +21,7 @@ static int count_argc(const char *str)
int count = 0; int count = 0;
while (*str) { while (*str) {
str = skip_sep(str); str = skip_spaces(str);
if (*str) { if (*str) {
count++; count++;
str = skip_arg(str); str = skip_arg(str);
...@@ -82,7 +75,7 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp) ...@@ -82,7 +75,7 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp)
argvp = argv; argvp = argv;
while (*str) { while (*str) {
str = skip_sep(str); str = skip_spaces(str);
if (*str) { if (*str) {
const char *p = str; const char *p = str;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/dynamic_debug.h> #include <linux/dynamic_debug.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
...@@ -209,8 +210,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) ...@@ -209,8 +210,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
char *end; char *end;
/* Skip leading whitespace */ /* Skip leading whitespace */
while (*buf && isspace(*buf)) buf = skip_spaces(buf);
buf++;
if (!*buf) if (!*buf)
break; /* oh, it was trailing whitespace */ break; /* oh, it was trailing whitespace */
......
...@@ -1766,13 +1766,6 @@ EXPORT_SYMBOL_GPL(bprintf); ...@@ -1766,13 +1766,6 @@ EXPORT_SYMBOL_GPL(bprintf);
#endif /* CONFIG_BINARY_PRINTF */ #endif /* CONFIG_BINARY_PRINTF */
static noinline char *skip_space(const char *str)
{
while (isspace(*str))
++str;
return (char *)str;
}
/** /**
* vsscanf - Unformat a buffer into a list of arguments * vsscanf - Unformat a buffer into a list of arguments
* @buf: input buffer * @buf: input buffer
...@@ -1794,8 +1787,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args) ...@@ -1794,8 +1787,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
* white space, including none, in the input. * white space, including none, in the input.
*/ */
if (isspace(*fmt)) { if (isspace(*fmt)) {
fmt = skip_space(fmt); fmt = skip_spaces(++fmt);
str = skip_space(str); str = skip_spaces(str);
} }
/* anything that is not a conversion must match exactly */ /* 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,7 +1858,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
if (field_width == -1) if (field_width == -1)
field_width = INT_MAX; field_width = INT_MAX;
/* first, skip leading white space in buffer */ /* first, skip leading white space in buffer */
str = skip_space(str); str = skip_spaces(str);
/* now copy until next white space */ /* now copy until next white space */
while (*str && !isspace(*str) && field_width--) while (*str && !isspace(*str) && field_width--)
...@@ -1907,7 +1900,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args) ...@@ -1907,7 +1900,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
/* have some sort of integer conversion. /* have some sort of integer conversion.
* first, skip white space in buffer. * first, skip white space in buffer.
*/ */
str = skip_space(str); str = skip_spaces(str);
digit = *str; digit = *str;
if (is_sign && digit == '-') if (is_sign && digit == '-')
......
...@@ -249,6 +249,7 @@ ...@@ -249,6 +249,7 @@
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/ctype.h> /* isspace() */ #include <linux/ctype.h> /* isspace() */
#include <linux/string.h> /* skip_spaces() */
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/init.h> #include <linux/init.h>
......
...@@ -77,8 +77,7 @@ irnet_ctrl_write(irnet_socket * ap, ...@@ -77,8 +77,7 @@ irnet_ctrl_write(irnet_socket * ap,
start = next; start = next;
/* Scrap whitespaces before the command */ /* Scrap whitespaces before the command */
while(isspace(*start)) start = skip_spaces(start);
start++;
/* ',' is our command separator */ /* ',' is our command separator */
next = strchr(start, ','); next = strchr(start, ',');
...@@ -133,8 +132,7 @@ irnet_ctrl_write(irnet_socket * ap, ...@@ -133,8 +132,7 @@ irnet_ctrl_write(irnet_socket * ap,
char * endp; char * endp;
/* Scrap whitespaces before the command */ /* Scrap whitespaces before the command */
while(isspace(*begp)) begp = skip_spaces(begp);
begp++;
/* Convert argument to a number (last arg is the base) */ /* Convert argument to a number (last arg is the base) */
addr = simple_strtoul(begp, &endp, 16); addr = simple_strtoul(begp, &endp, 16);
......
...@@ -482,8 +482,7 @@ static ssize_t recent_old_proc_write(struct file *file, ...@@ -482,8 +482,7 @@ static ssize_t recent_old_proc_write(struct file *file,
if (copy_from_user(buf, input, size)) if (copy_from_user(buf, input, size))
return -EFAULT; return -EFAULT;
while (isspace(*c)) c = skip_spaces(c);
c++;
if (size - (c - buf) < 5) if (size - (c - buf) < 5)
return c - buf; return c - buf;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/string.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <sound/core.h> #include <sound/core.h>
#include "hda_codec.h" #include "hda_codec.h"
...@@ -428,8 +429,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf) ...@@ -428,8 +429,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf)
char *key, *val; char *key, *val;
struct hda_hint *hint; struct hda_hint *hint;
while (isspace(*buf)) buf = skip_spaces(buf);
buf++;
if (!*buf || *buf == '#' || *buf == '\n') if (!*buf || *buf == '#' || *buf == '\n')
return 0; return 0;
if (*buf == '=') if (*buf == '=')
...@@ -444,8 +444,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf) ...@@ -444,8 +444,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf)
return -EINVAL; return -EINVAL;
} }
*val++ = 0; *val++ = 0;
while (isspace(*val)) val = skip_spaces(val);
val++;
remove_trail_spaces(key); remove_trail_spaces(key);
remove_trail_spaces(val); remove_trail_spaces(val);
hint = get_hint(codec, key); hint = get_hint(codec, key);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment