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

2022-01-20 Thread Joe Perches
On Wed, 2022-01-19 at 16:00 -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... > > Checkpatch says

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

2022-01-20 Thread David Laight
> > > > +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. - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

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

2022-01-20 Thread Sakari Ailus
Hi Lucas, 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) > tomoyo_io_printf(head, "

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

2022-01-20 Thread Lucas De Marchi
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 286 $ git grep '?\s*"no"\s*' | wc -l 20 The inlined function should

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] [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 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] [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 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 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 >