Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread David Laight
> > except '"no\0\0yes" + v * 4' works a bit better. > > Is it a C code obfuscation contest? That would be: return &(v * 3)["no\0yes"]; :-) - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

Re: [Nouveau] [Intel-gfx] [PATCH 0/3] lib/string_helpers: Add a few string helpers

2022-01-19 Thread Andy Shevchenko
On Wed, Jan 19, 2022 at 12:53:43PM -0800, Lucas De Marchi wrote: > On Wed, Jan 19, 2022 at 05:15:02PM +0100, Daniel Vetter wrote: > > On Wed, Jan 19, 2022 at 04:16:12PM +0200, Jani Nikula wrote: ... > > Yeah we can sed this anytime later we want to, but we need to get the foot > > in the door.

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread Andy Shevchenko
On Wed, Jan 19, 2022 at 04:00:17PM -0500, Steven Rostedt wrote: > On Wed, 19 Jan 2022 21:25:08 +0200 > Andy Shevchenko wrote: > > > > I say keep it one line! > > > > > > Reviewed-by: Steven Rostedt (Google) > > > > I believe Sakari strongly follows the 80 rule, which means... > >

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread Steven Rostedt
On Wed, 19 Jan 2022 21:25:08 +0200 Andy Shevchenko wrote: > > I say keep it one line! > > > > Reviewed-by: Steven Rostedt (Google) > > I believe Sakari strongly follows the 80 rule, which means... Checkpatch says "100" I think we need to simply update the docs (the documentation always

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread Steven Rostedt
On Wed, 19 Jan 2022 21:22:57 +0200 Andy Shevchenko wrote: > On Wed, Jan 19, 2022 at 04:38:26PM +, David Laight wrote: > > > > > > +static inline const char *yesno(bool v) { return v ? "yes" : "no"; > > > > > > } > > > > > > return "yes\0no" + v * 4; > > > > > > :-) > > > > except

Re: [Nouveau] [PATCH 3/3] drm: Convert open yes/no strings to yesno()

2022-01-19 Thread Andy Shevchenko
On Tue, Jan 18, 2022 at 11:24:50PM -0800, Lucas De Marchi wrote: > linux/string_helpers.h provides a helper to return "yes"/"no" > strings. Replace the open coded versions with yesno(). The places were > identified with the following semantic patch: > > @@ > expression b; > @@ >

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread Andy Shevchenko
On Wed, Jan 19, 2022 at 04:38:26PM +, David Laight wrote: > > > > > +static inline const char *yesno(bool v) { return v ? "yes" : "no"; } > > > > return "yes\0no" + v * 4; > > > > :-) > > except '"no\0\0yes" + v * 4' works a bit better. Is it a C code obfuscation contest? -- With

Re: [Nouveau] [RFC PATCH v3 2/3] drm: add support modifiers for drivers whose planes only support linear layout

2022-01-19 Thread Andy Shevchenko
On Wed, Jan 19, 2022 at 11:35:22AM +0900, Esaki Tomohito wrote: > On 2022/01/18 18:53, Andy Shevchenko wrote: > > On Mon, Jan 17, 2022 at 02:15:48PM +0900, Esaki Tomohito wrote: > > > On 2022/01/14 23:16, Andy Shevchenko wrote: > > > > On Fri, Jan 14, 2022 at 07:17:52PM +0900, Tomohito Esaki

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread Andy Shevchenko
On Wed, Jan 19, 2022 at 10:06:35AM -0500, Steven Rostedt wrote: > On Wed, 19 Jan 2022 11:18:59 +0200 > Sakari Ailus wrote: > > On Tue, Jan 18, 2022 at 11:24:48PM -0800, Lucas De Marchi wrote: > > > @@ -1354,8 +1345,7 @@ static bool tomoyo_print_condition(struct > > > tomoyo_io_buffer *head, > >

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread David Laight
> > > +static inline const char *yesno(bool v) { return v ? "yes" : "no"; } return "yes\0no" + v * 4; :-) - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

Re: [Nouveau] [PATCH 0/3] lib/string_helpers: Add a few string helpers

2022-01-19 Thread Daniel Vetter
On Wed, Jan 19, 2022 at 04:16:12PM +0200, Jani Nikula wrote: > On Wed, 19 Jan 2022, Petr Mladek wrote: > > On Tue 2022-01-18 23:24:47, Lucas De Marchi wrote: > >> Add some helpers under lib/string_helpers.h so they can be used > >> throughout the kernel. When I started doing this there were 2

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread Steven Rostedt
On Wed, 19 Jan 2022 11:18:59 +0200 Sakari Ailus wrote: > On Tue, Jan 18, 2022 at 11:24:48PM -0800, Lucas De Marchi wrote: > > @@ -1354,8 +1345,7 @@ static bool tomoyo_print_condition(struct > > tomoyo_io_buffer *head, > > case 3: > > if (cond->grant_log != TOMOYO_GRANTLOG_AUTO)

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread Steven Rostedt
On Wed, 19 Jan 2022 11:15:08 +0200 Andy Shevchenko wrote: > > +static inline const char *yesno(bool v) { return v ? "yes" : "no"; } > > > > Perhaps keep it on 4 lines? Yes, yes/no is short, but if we add others > (enable/disable) it will not be possible to keep on one line. And hence >

Re: [Nouveau] [PATCH 0/3] lib/string_helpers: Add a few string helpers

2022-01-19 Thread Jani Nikula
On Wed, 19 Jan 2022, Petr Mladek wrote: > On Tue 2022-01-18 23:24:47, Lucas De Marchi wrote: >> Add some helpers under lib/string_helpers.h so they can be used >> throughout the kernel. When I started doing this there were 2 other >> previous attempts I know of, not counting the iterations each

Re: [Nouveau] [PATCH 0/3] lib/string_helpers: Add a few string helpers

2022-01-19 Thread Andy Shevchenko
On Wednesday, January 19, 2022, Lucas De Marchi wrote: > Add some helpers under lib/string_helpers.h so they can be used > throughout the kernel. When I started doing this there were 2 other > previous attempts I know of, not counting the iterations each of them > had: > > 1)

Re: [Nouveau] [PATCH 2/3] lib/string_helpers: Add helpers for enable[d]/disable[d]

2022-01-19 Thread Andy Shevchenko
On Wednesday, January 19, 2022, Lucas De Marchi wrote: > Follow the yes/no logic and add helpers for enabled/disabled and > enable/disable - those are not so common throughout the kernel, > but they give a nice way to reuse the strings to log things as > enabled/disabled or enable/disable. > >

Re: [Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation

2022-01-19 Thread Andy Shevchenko
On Wednesday, January 19, 2022, Lucas De Marchi wrote: > There are a few implementations of yesno() in the tree. Consolidate them > in include/linux/string_helpers.h. Quite a few users of open coded > yesno() could later be converted to the new function: > > $ git grep '?\s*"yes"\s*' | wc -l >

Re: [Nouveau] [PATCH 0/3] lib/string_helpers: Add a few string helpers

2022-01-19 Thread Jani Nikula
On Tue, 18 Jan 2022, Lucas De Marchi wrote: > Add some helpers under lib/string_helpers.h so they can be used > throughout the kernel. When I started doing this there were 2 other > previous attempts I know of, not counting the iterations each of them > had: > > 1)