Re: more potential janitor work: simplifying test for power of 2

Linus Probert
2026-04-02T13:04:36Z

On Thu Apr 2, 2026 at 2:40 PM CEST, Robert P. J. Day wrote:
> On Thu, 2 Apr 2026, Linus Probert wrote:
>
>> On Thu Apr 2, 2026 at 12:07 PM CEST, Julia Lawall wrote:
>> >
>> >
>> > On Thu, 2 Apr 2026, Linus Probert wrote:
>> >

[...]

>
> Not to toot my own horn but if you go back through history, I was
> the one who kicked off the introduction of the first "is power of 2"
> helper function many, many years ago:

Totally worth a toot, it's a neat piece of bit operation.

[...]

> And, no, a lot of that content was not immediately obvious as a
> candidate for simplification; when I wrote my regex searching scripts,
> I deliberately made them overly general *knowing* I would get false
> positives, then I manually checked whether they should be simplified.
> It never occurred to me that some of those checks were actually asking
> whether more than one bit flag was set, which semantically is asking a
> different question.

Throwing a wide net makes sense. I first noted this alternate 'question'
pattern after some scrolling. Didn't consider that case at first.

Just wanted to share that finding since others might have picked up on
this opportunity to contribute and perhaps not noticed the "semantic
difference".

> Anyway, people were asking about janitorial work so I threw out a
> couple of ideas. Whether they're worth pursing ... not my call.

I was asking and appreciate the suggestions. If you have more stuff
knocking about I'm certain it will be appreciated by some of us
neophytes.

I'm learning that the hard part isn't immediately the code change. The
whole email patch cycle and high standards on commit message subject and
content takes some getting used to.

I doubt the kernel project is a large contributor to
https://latenightcommits.com/ :)

Br,
Linus