]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
argv_split: allow argv_split to handle NULL pointer in argcp parameter gracefully
authorNeil Horman <nhorman@tuxdriver.com>
Wed, 17 Oct 2007 06:26:33 +0000 (23:26 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 17 Oct 2007 15:42:50 +0000 (08:42 -0700)
It would be nice if the argv_split library function could gracefully handle
a NULL pointer in the argcp parameter, so as to allow functions using it
that did not care about the value of argc to not have to declare a useless
variable.  This patch accomplishes that.  Tested by me, with successful
results.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Satyam Sharma <satyam@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/argv_split.c

index 4096ed42f490869c252b1e33ea76050fe8f1ec92..fad6ce4f7b57e353bf9b4a9d8c2dca502b4d5938 100644 (file)
@@ -75,7 +75,9 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp)
        if (argv == NULL)
                goto out;
 
-       *argcp = argc;
+       if (argcp)
+               *argcp = argc;
+
        argvp = argv;
 
        while (*str) {