Pavel Machek <[email protected]> wrote:
> [email protected] said:
> > The attached patch:
> > o Fixes kernel/power/disk.c string declared as 'char *p = "...";' to be
> > declared as 'char p[] = "...";', as pointed by Jeff Garzik.
>
> ? Why was char *p ... wrong? Because you could not do sizeof() later?
Note also that this increases the stack usage of the function and slows it
down, as this means allocating an array and filling it in at call time.
>
> > o Replaces:
> > i++:
> > if (i > 3) i = 0;
> >
> > By:
> > i = (i + 1) % (sizeof(p) - 1);
> >
> > Which is if-less, and the adjust value is evaluated by the compiler in
> > compile-time in case the string related to this loop is modified.
>
> Well, why not...
Because for that it could be done with a #define of the string... and it is
not that this could change any time soon, so IMHO a constant 3 + comment
would be fine.
--
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]