mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Herbert Xu' <herbert@gondor.apana.org.au>,
	"menglong8.dong@gmail.com" <menglong8.dong@gmail.com>
Cc: "andy.shevchenko@gmail.com" <andy.shevchenko@gmail.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"linux@roeck-us.net" <linux@roeck-us.net>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"dong.menglong@zte.com.cn" <dong.menglong@zte.com.cn>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH net-next 2/2] net: socket: change MSG_CMSG_COMPAT to BIT(21)
Date: Mon, 22 Mar 2021 08:58:11 +0000	[thread overview]
Message-ID: <ab55a91d390c485187326c8fa3a84841@AcuMS.aculab.com> (raw)
In-Reply-To: <20210321124906.GA14333@gondor.apana.org.au>

From: Herbert Xu
> Sent: 21 March 2021 12:49
> 
> On Sun, Mar 21, 2021 at 08:39:29PM +0800, menglong8.dong@gmail.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)


      parent reply	other threads:[~2021-03-22  8:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21 12:39 [PATCH net-next 0/2] net: socket: use BIT() for MSG_* and fix MSG_CMSG_COMPAT menglong8.dong
2021-03-21 12:39 ` [PATCH net-next 1/2] net: socket: use BIT() for MSG_* menglong8.dong
2021-03-21 12:39 ` [PATCH net-next 2/2] net: socket: change MSG_CMSG_COMPAT to BIT(21) menglong8.dong
2021-03-21 12:49   ` Herbert Xu
2021-03-21 13:29     ` Menglong Dong
2021-03-22  8:58     ` David Laight [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab55a91d390c485187326c8fa3a84841@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=dong.menglong@zte.com.cn \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=menglong8.dong@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®