[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <056cfcf737e344acb47d612f642d58b3@AcuMS.aculab.com>
Date: Sun, 25 Feb 2024 21:09:29 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Linus Torvalds' <torvalds@...ux-foundation.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Netdev
<netdev@...r.kernel.org>, "dri-devel@...ts.freedesktop.org"
<dri-devel@...ts.freedesktop.org>, Jens Axboe <axboe@...nel.dk>, "Matthew
Wilcox (Oracle)" <willy@...radead.org>, Christoph Hellwig
<hch@...radead.org>, "linux-btrfs@...r.kernel.org"
<linux-btrfs@...r.kernel.org>, Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, "David S . Miller"
<davem@...emloft.net>, Dan Carpenter <dan.carpenter@...aro.org>, Jani Nikula
<jani.nikula@...ux.intel.com>
Subject: RE: [PATCH next v2 08/11] minmax: Add min_const() and max_const()
From: Linus Torvalds
> Sent: 25 February 2024 17:14
>
> On Sun, 25 Feb 2024 at 08:53, David Laight <David.Laight@...lab.com> wrote:
> >
> > The expansions of min() and max() contain statement expressions so are
> > not valid for static intialisers.
> > min_const() and max_const() are expressions so can be used for static
> > initialisers.
>
> I hate the name.
Picking name is always hard...
> Naming shouldn't be about an implementation detail, particularly not
> an esoteric one like the "C constant expression" rule. That can be
> useful for some internal helper functions or macros, but not for
> something that random people are supposed to USE.
>
> Telling some random developer that inside an array size declaration or
> a static initializer you need to use "max_const()" because it needs to
> syntactically be a constant expression, and our regular "max()"
> function isn't that, is just *horrid*.
>
> No, please just use the traditional C model of just using ALL CAPS for
> macro names that don't act like a function.
>
> Yes, yes, that may end up requiring getting rid of some current users of
>
> #define MIN(a,b) ((a)<(b) ? (a):(b))
>
> but dammit, we don't actually have _that_ many of them, and why should
> we have random drivers doing that anyway?
I'll have a look at what is there.
It might take a three part patch though.
Unless you apply it as a tree-wide patch?
One option is to add as max_const(), then change any existing MAX()
to be max() or max_const() and then finally rename to MAX()?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists