Re: [RFC] Re: Parsing kernel parameters and escaping "

From: Rusty Russell
Date: Mon Jul 13 2009 - 22:49:58 EST


On Mon, 13 Jul 2009 12:19:17 pm Daniel Mierswa wrote:
> Rusty Russell wrote:
> > It might be nice to have that test code somewhere at the bottom of
> > param.c, at least while we're playing with the code.
>
> Umm, I'm not sure where test-code is supposed to go in kernel code.
> Should it be a main() function, a test() function, just a comment, could
> you elaborate? All i did now was to build a small program that reads
> argv[1] and uses next_arg just like parse_args() in params.c does.

Usually I write a function like:

#if 0
static int param_result(char *param, char *val)
{
static int expect;
const char *params[] = { "foo", "foo", ... };
const char *vals[] = "bar", NULL, ...};

BUG_ON(strcmp(param,params[expect]) != 0);
if (vals[expect] == NULL)
BUGON(val);
else
BUGON(strcmp(val, vals[expect]) != 0);
}

static int test_params(void)
{
char *str = kstrdup("foo=bar foo ...", GFP_KERNEL);
parse_args("test", str, NULL, 0, param_result);
return 0;
}
module_init(test_params);
#endif

> > Thanks!
>
> Ditto.

Thanks for all the work!
Rusty.
--
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/