David Laight
2022-Jan-19 16:37 UTC
[Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation
> > > +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)
David Laight
2022-Jan-19 16:38 UTC
[Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation
> > > > +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)
Andy Shevchenko
2022-Jan-19 19:22 UTC
[Nouveau] [PATCH 1/3] lib/string_helpers: Consolidate yesno() implementation
On Wed, Jan 19, 2022 at 04:38:26PM +0000, 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 Best Regards, Andy Shevchenko