* [KJ] another cleanup TO DO: is_power_of_2() check
@ 2007-01-08 22:37 Robert P. J. Day
2007-01-08 23:09 ` Frederik Deweerdt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Robert P. J. Day @ 2007-01-08 22:37 UTC (permalink / raw)
To: kernel-janitors
there are *numerous* places in the code that check if some value is
a power of 2 using the basic test "((x & (x - 1)) = 0)":
$ grep -Er "(.*) ?\& ?\(\1 ?- ?1\)" .
as you can see, that test is all over the place.
occasionally, someone decides to do the right thing and define a
macro:
$ grep -r "#define is_power_of_2" .
i'm thinking it might be cleaner to define that macro in kernel.h and
clean up the source to use that macro, rather than constantly
rewriting that expression.
thoughts?
rday
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [KJ] another cleanup TO DO: is_power_of_2() check
2007-01-08 22:37 [KJ] another cleanup TO DO: is_power_of_2() check Robert P. J. Day
@ 2007-01-08 23:09 ` Frederik Deweerdt
2007-01-08 23:15 ` Robert P. J. Day
2007-01-09 0:06 ` Frederik Deweerdt
2 siblings, 0 replies; 4+ messages in thread
From: Frederik Deweerdt @ 2007-01-08 23:09 UTC (permalink / raw)
To: kernel-janitors
On Mon, Jan 08, 2007 at 05:37:16PM -0500, Robert P. J. Day wrote:
>
> there are *numerous* places in the code that check if some value is
> a power of 2 using the basic test "((x & (x - 1)) = 0)":
>
> $ grep -Er "(.*) ?\& ?\(\1 ?- ?1\)" .
>
> as you can see, that test is all over the place.
>
> occasionally, someone decides to do the right thing and define a
> macro:
>
> $ grep -r "#define is_power_of_2" .
Some of which really are is_power_of_2_but_not_0 :). That corner case
set aside, but it is handled differently throughout the source, it seems
fine to me.
Regards,
Frederik
>
> i'm thinking it might be cleaner to define that macro in kernel.h and
> clean up the source to use that macro, rather than constantly
> rewriting that expression.
>
> thoughts?
>
> rday
> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors
>
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [KJ] another cleanup TO DO: is_power_of_2() check
2007-01-08 22:37 [KJ] another cleanup TO DO: is_power_of_2() check Robert P. J. Day
2007-01-08 23:09 ` Frederik Deweerdt
@ 2007-01-08 23:15 ` Robert P. J. Day
2007-01-09 0:06 ` Frederik Deweerdt
2 siblings, 0 replies; 4+ messages in thread
From: Robert P. J. Day @ 2007-01-08 23:15 UTC (permalink / raw)
To: kernel-janitors
On Mon, 8 Jan 2007, Frederik Deweerdt wrote:
> On Mon, Jan 08, 2007 at 05:37:16PM -0500, Robert P. J. Day wrote:
> >
> > there are *numerous* places in the code that check if some value is
> > a power of 2 using the basic test "((x & (x - 1)) = 0)":
> >
> > $ grep -Er "(.*) ?\& ?\(\1 ?- ?1\)" .
> >
> > as you can see, that test is all over the place.
> >
> > occasionally, someone decides to do the right thing and define a
> > macro:
> >
> > $ grep -r "#define is_power_of_2" .
> Some of which really are is_power_of_2_but_not_0 :).
yes, i had noticed that.
> That corner case set aside, but it is handled differently throughout
> the source, it seems fine to me.
*what* seems fine? making the change, or leaving it as is?
rday
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [KJ] another cleanup TO DO: is_power_of_2() check
2007-01-08 22:37 [KJ] another cleanup TO DO: is_power_of_2() check Robert P. J. Day
2007-01-08 23:09 ` Frederik Deweerdt
2007-01-08 23:15 ` Robert P. J. Day
@ 2007-01-09 0:06 ` Frederik Deweerdt
2 siblings, 0 replies; 4+ messages in thread
From: Frederik Deweerdt @ 2007-01-09 0:06 UTC (permalink / raw)
To: kernel-janitors
> *what* seems fine? making the change, or leaving it as is?
>
Making the change.
Regards,
Frederik
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-01-09 0:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-08 22:37 [KJ] another cleanup TO DO: is_power_of_2() check Robert P. J. Day
2007-01-08 23:09 ` Frederik Deweerdt
2007-01-08 23:15 ` Robert P. J. Day
2007-01-09 0:06 ` Frederik Deweerdt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.