Re: [PATCH 3/3] Allow arbitrary number of init funcs in modules

Horst von Brand (vonbrand@inf.utfsm.cl)
Tue, 24 Jun 2003 16:06:36 -0400


corbet@lwn.net (Jonathan Corbet) said:
> --- 2.5.73-rr/kernel/module.c Tue Jun 24 02:58:32 2003
> +++ 2.5.73/kernel/module.c Tue Jun 24 03:00:36 2003
> @@ -617,9 +617,10 @@
> {
> int i, balance = 0;
>
> - for (i = 0; i < num_pairs; i++)
> + for (i = 0; i < num_pairs; i++) {
> balance += (pairs->init ? 1 : 0) - (pairs->exit ? 1 : 0);
> -
> + pairs++;
> + }

Hummm... as you are essentially counting off pairs, isn't there a way of
detecting end-of-pairs, i.e. along the line (last points to NULL):

for(pairs = start_of_pairs; *pairs; pairs++)
....

or just:

for(i = 0; i < num_pairs; i++)
balance += (pairs[i].init ? 1 : 0) - (pairs[i].exit ? 1 : 0);

(as added bonus doesn't screw up variable pairs' value), or even (same as
yours above but marginally clearer IMEHO):

for (i = 0; i < num_pairs; i++, pairs++)
.....

-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/