From: menglong8.dong@gmail.com
To: herbert@gondor.apana.org.au, andy.shevchenko@gmail.com,
kuba@kernel.org, linux@roeck-us.net, David.Laight@aculab.com
Cc: davem@davemloft.net, dong.menglong@zte.com.cn,
viro@zeniv.linux.org.uk, axboe@kernel.dk,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH v2 net-next 1/2] net: socket: use BIT() for MSG_*
Date: Sun, 21 Mar 2021 21:43:56 +0800 [thread overview]
Message-ID: <20210321134357.148323-2-dong.menglong@zte.com.cn> (raw)
In-Reply-To: <20210321134357.148323-1-dong.menglong@zte.com.cn>
From: Menglong Dong <dong.menglong@zte.com.cn>
The bit mask for MSG_* seems a little confused here. Replace it
with BIT() to make it clear to understand.
Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
---
include/linux/socket.h | 71 ++++++++++++++++++++++--------------------
1 file changed, 37 insertions(+), 34 deletions(-)
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 385894b4a8bb..d5ebfe30d96b 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -283,42 +283,45 @@ struct ucred {
Added those for 1003.1g not all are supported yet
*/
-#define MSG_OOB 1
-#define MSG_PEEK 2
-#define MSG_DONTROUTE 4
-#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */
-#define MSG_CTRUNC 8
-#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */
-#define MSG_TRUNC 0x20
-#define MSG_DONTWAIT 0x40 /* Nonblocking io */
-#define MSG_EOR 0x80 /* End of record */
-#define MSG_WAITALL 0x100 /* Wait for a full request */
-#define MSG_FIN 0x200
-#define MSG_SYN 0x400
-#define MSG_CONFIRM 0x800 /* Confirm path validity */
-#define MSG_RST 0x1000
-#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */
-#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */
-#define MSG_MORE 0x8000 /* Sender will send more */
-#define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */
-#define MSG_SENDPAGE_NOPOLICY 0x10000 /* sendpage() internal : do no apply policy */
-#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */
-#define MSG_BATCH 0x40000 /* sendmmsg(): more messages coming */
-#define MSG_EOF MSG_FIN
-#define MSG_NO_SHARED_FRAGS 0x80000 /* sendpage() internal : page frags are not shared */
-#define MSG_SENDPAGE_DECRYPTED 0x100000 /* sendpage() internal : page may carry
- * plain text and require encryption
- */
-
-#define MSG_ZEROCOPY 0x4000000 /* Use user data in kernel path */
-#define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
-#define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exec for file
- descriptor received through
- SCM_RIGHTS */
+#define MSG_OOB BIT(0)
+#define MSG_PEEK BIT(1)
+#define MSG_DONTROUTE BIT(2)
+#define MSG_TRYHARD BIT(2) /* Synonym for MSG_DONTROUTE for DECnet */
+#define MSG_CTRUNC BIT(3)
+#define MSG_PROBE BIT(4) /* Do not send. Only probe path f.e. for MTU */
+#define MSG_TRUNC BIT(5)
+#define MSG_DONTWAIT BIT(6) /* Nonblocking io */
+#define MSG_EOR BIT(7) /* End of record */
+#define MSG_WAITALL BIT(8) /* Wait for a full request */
+#define MSG_FIN BIT(9)
+#define MSG_SYN BIT(10)
+#define MSG_CONFIRM BIT(11) /* Confirm path validity */
+#define MSG_RST BIT(12)
+#define MSG_ERRQUEUE BIT(13) /* Fetch message from error queue */
+#define MSG_NOSIGNAL BIT(14) /* Do not generate SIGPIPE */
+#define MSG_MORE BIT(15) /* Sender will send more */
+#define MSG_WAITFORONE BIT(16) /* recvmmsg(): block until 1+ packets avail */
+#define MSG_SENDPAGE_NOPOLICY BIT(16) /* sendpage() internal : do no apply policy */
+#define MSG_SENDPAGE_NOTLAST BIT(17) /* sendpage() internal : not the last page */
+#define MSG_BATCH BIT(18) /* sendmmsg(): more messages coming */
+#define MSG_EOF MSG_FIN
+#define MSG_NO_SHARED_FRAGS BIT(19) /* sendpage() internal : page frags
+ * are not shared
+ */
+#define MSG_SENDPAGE_DECRYPTED BIT(20) /* sendpage() internal : page may carry
+ * plain text and require encryption
+ */
+
+#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 0x80000000 /* This message needs 32 bit fixups */
+#define MSG_CMSG_COMPAT BIT(31) /* This message needs 32 bit fixups */
#else
-#define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */
+#define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */
#endif
--
2.30.2
next prev parent reply other threads:[~2021-03-21 13:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 13:43 [PATCH v2 net-next 0/2] net: socket: use BIT() for MSG_* and fix MSG_CMSG_COMPAT menglong8.dong
2021-03-21 13:43 ` menglong8.dong [this message]
2021-03-21 16:15 ` [PATCH v2 net-next 1/2] net: socket: use BIT() for MSG_* Guenter Roeck
2021-03-21 13:43 ` [PATCH v2 net-next 2/2] net: socket: change MSG_CMSG_COMPAT to BIT(21) menglong8.dong
2021-03-21 16:20 ` Guenter Roeck
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=20210321134357.148323-2-dong.menglong@zte.com.cn \
--to=menglong8.dong@gmail.com \
--cc=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=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;
as well as URLs for NNTP newsgroup(s).