Re: [patch 2/4] add argv_split()

From: Randy Dunlap
Date: Tue May 08 2007 - 17:57:52 EST


On Tue, 08 May 2007 13:51:31 -0700 Jeremy Fitzhardinge wrote:

> --- /dev/null
> +++ b/lib/argv_split.c
> @@ -0,0 +1,160 @@
> +
> +static const char *skip_sep(const char *cp)
> +{
> + while(*cp && isspace(*cp))

Kernel style is space after "while", "for", "if"...

> + cp++;
> +
> + return cp;
> +}
> +
> +static const char *skip_arg(const char *cp)
> +{
> + while(*cp && !isspace(*cp))
> + cp++;
> +
> + return cp;
> +}
> +
> +static int count_argc(const char *str)
> +{
> + int count = 0;
> +
> + while(*str) {
> + str = skip_sep(str);
> + if (*str) {
> + count++;
> + str = skip_arg(str);
> + }
> + }
> +
> + return count;
> +}
> +
> +/**
> + * argv_free - free an argv
> + *

no blank "*" line.

> + * @argv - the argument vector to be freed

* @argv: the argument vector to be freed


> + *
> + * Frees an argv and the strings it points to.
> + */
> +void argv_free(char **argv)
> +{
> + char **p;
> + for(p = argv; *p; p++)
> + kfree(*p);
> +
> + kfree(argv);
> +}
> +EXPORT_SYMBOL(argv_free);


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/