[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ab55a91d390c485187326c8fa3a84841@AcuMS.aculab.com>
Date: Mon, 22 Mar 2021 08:58:11 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Herbert Xu' <herbert@...dor.apana.org.au>,
"menglong8.dong@...il.com" <menglong8.dong@...il.com>
CC: "andy.shevchenko@...il.com" <andy.shevchenko@...il.com>,
"kuba@...nel.org" <kuba@...nel.org>,
"linux@...ck-us.net" <linux@...ck-us.net>,
"davem@...emloft.net" <davem@...emloft.net>,
"dong.menglong@....com.cn" <dong.menglong@....com.cn>,
"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>,
"axboe@...nel.dk" <axboe@...nel.dk>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH net-next 2/2] net: socket: change MSG_CMSG_COMPAT to
BIT(21)
From: Herbert Xu
> Sent: 21 March 2021 12:49
>
> On Sun, Mar 21, 2021 at 08:39:29PM +0800, menglong8.dong@...il.com wrote:
> >
> > diff --git a/include/linux/socket.h b/include/linux/socket.h
> > index d5ebfe30d96b..317b2933f499 100644
> > --- a/include/linux/socket.h
> > +++ b/include/linux/socket.h
> > @@ -312,17 +312,18 @@ struct ucred {
> > * plain text and require encryption
> > */
> >
> > +#if defined(CONFIG_COMPAT)
> > +#define MSG_CMSG_COMPAT BIT(21) /* This message needs 32 bit fixups */
> > +#else
> > +#define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */
> > +#endif
> > +
> > #define MSG_ZEROCOPY BIT(26) /* Use user data in kernel path */
> > #define MSG_FASTOPEN BIT(29) /* Send data in TCP SYN */
> > #define MSG_CMSG_CLOEXEC BIT(30) /* Set close_on_exec for file
> > * descriptor received through
> > * SCM_RIGHTS
> > */
> > -#if defined(CONFIG_COMPAT)
> > -#define MSG_CMSG_COMPAT BIT(31) /* This message needs 32 bit fixups */
> > -#else
> > -#define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */
> > -#endif
>
> Shouldn't you add some comment here to stop people from trying to
> use BIT(31) in the future?
You'd also be better using BIT(30) - ie the other end of the
free space from the user-visible bits.
It has to be said that the entire impossibility of writing BIT(n)
safely almost makes it worse that just defining appropriate constants.
Personally I like the hex constants.
The make it much easier to work out which bits are set in a diagnostic
print (or memory hexdump).
The only time I've really found BIT() type macros useful is when
defining values that have to match hardware specs that define bit
numbers backwards starting from 1.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists