Re: [PATCH 2/2] tracing: Use switch statement instead of ifs in set_tracer_flag()

From: Steven Rostedt
Date: Mon Nov 10 2025 - 11:58:06 EST


On Mon, 10 Nov 2025 14:48:26 +0900
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:

> BTW, set_tracer_flag() seems to expect to modify only one bit.
> If we can count the number of its in @mask and reject if it is
> not 1, we can use bit-mask instead of the first switch()?
>
> if (!mask || /* mask has no bit */
> (mask & ~(1 << (ffs64(mask) - 1)))) /* mask has more than 2 bits */
> return -EINVAL;

Well, this has been around for over a decade without any issues. I don't
think a check would be of much use. Not to mention, invalid masks are OK to
pass in.

If anything, I would have liked to pass in the bit number and not a mask.
But that's something we could do another time.

-- Steve