Re: C99 Initialisers

From: Dagfinn Ilmari MannsÃker
Date: Mon Aug 11 2003 - 22:03:24 EST


Matthew Wilcox <willy@xxxxxxxxxx> writes:

> On Mon, Aug 11, 2003 at 07:18:53PM -0700, Robert Love wrote:
>> Convert GNU-style to C99-style. I think converting unnamed initializers
>> to named initializers is a Good Thing, too.
>
> By and large ... here's a counterexample:

[snip unnamed initialisation]

> I don't think anyone would appreciate you converting that to:

[snip C99 named initialisation]

To the contrary (and I agree with Jeff):

From: Jeff Garzik <jgarzik@xxxxxxxxx>
To: davej@xxxxxxxxxx
Cc: torvalds@xxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
Subject: Re: [PATCH] c99 initialisers for random.c
Message-ID: <20030811144709.GA32180@xxxxxxx>
References: <E19mCuO-0003da-00@tetrachloride>

On Mon, Aug 11, 2003 at 02:40:24PM +0100, davej@xxxxxxxxxx wrote:
> diff -urpN --exclude-from=/home/davej/.exclude bk-linus/drivers/char/random.c linux-2.5/drivers/char/random.c
> --- bk-linus/drivers/char/random.c 2003-08-04 01:00:22.000000000 +0100
> +++ linux-2.5/drivers/char/random.c 2003-08-06 18:59:31.000000000 +0100
>@@ -1850,27 +1850,62 @@ static int uuid_strategy(ctl_table *tabl
> }
>
> ctl_table random_table[] = {
>- {RANDOM_POOLSIZE, "poolsize",
>- &sysctl_poolsize, sizeof(int), 0644, NULL,
>- &proc_do_poolsize, &poolsize_strategy},
[...]
>- {0}
>+ {
>+ .ctl_name = RANDOM_POOLSIZE,
>+ .procname = "poolsize",
>+ .data = &sysctl_poolsize,
>+ .maxlen = sizeof(int),
>+ .mode = 0644,
>+ .proc_handler = &proc_do_poolsize,
>+ .strategy = &poolsize_strategy,
>+ },
[...]
>+ { .ctl_name = 0 }
> };
>
> static void sysctl_init_random(struct entropy_store *random_state)

Wow. That is so much more clean (to my eyes).

Jeff

--
ilmari

-
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/