Re: [PATCH v2] staging: media: atomisp: Use str_on_off() to fix Coccinelle warning
From: Andy Shevchenko
Date: Fri Apr 24 2026 - 04:44:15 EST
On Thu, Apr 23, 2026 at 10:41:13PM +0100, David Laight wrote:
> On Thu, 23 Apr 2026 13:47:27 -0600
> Nick Spooner <nicholas.spooner@xxxxxxxxxxx> wrote:
...
> > dev_dbg(subdev->dev, "Setting power state to %s\n",
> > - on ? "on" : "off");
> > + str_on_off(on));
>
> While someone went to the trouble of adding the 'helper' and the Coccinelle
> warning; I'm not really convinced it actually improves the code.
> It doesn't even do &"off\0on"[on_off * 4] - which might be an excuse
> for a helper.
The point of the helper mainly not about the code optimisation, it's all about
making unified tokens when printing stuff (same for dates, times, escaped
strings, et cetera). Btw, the code like `&"off\0on"[on_off * 4]` is unreadable
trick. And I dunno if compiler/linker will be able to pack these string literals
as currently done in case several of str_FOO_BAR() [with the same FOO_BAR] are
in the same compilation unit.
--
With Best Regards,
Andy Shevchenko