diff options
author | Gu Zheng <guz.fnst@cn.fujitsu.com> | 2014-12-10 22:22:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-12-10 22:41:55 -0500 |
commit | f95b414edb18de59940dcebbefb49cf25c6d505c (patch) | |
tree | 654de508641fd2c82428f43387b72fd1a3dcef42 /net | |
parent | dd0bcc0bc842e0d2c981102376d867c1a8bad320 (diff) |
net: introduce helper macro for_each_cmsghdr
Introduce helper macro for_each_cmsghdr as a wrapper of the enumerating
cmsghdr from msghdr, just cleanup.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/scm.c | 3 | ||||
-rw-r--r-- | net/dccp/proto.c | 5 | ||||
-rw-r--r-- | net/ipv4/ip_sockglue.c | 2 | ||||
-rw-r--r-- | net/ipv6/datagram.c | 2 | ||||
-rw-r--r-- | net/iucv/af_iucv.c | 4 | ||||
-rw-r--r-- | net/rds/send.c | 4 | ||||
-rw-r--r-- | net/rxrpc/ar-output.c | 2 | ||||
-rw-r--r-- | net/sctp/socket.c | 3 |
8 files changed, 10 insertions, 15 deletions
diff --git a/net/core/scm.c b/net/core/scm.c index b442e7e25e60..3b6899b7d810 100644 --- a/net/core/scm.c +++ b/net/core/scm.c | |||
@@ -129,8 +129,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) | |||
129 | struct cmsghdr *cmsg; | 129 | struct cmsghdr *cmsg; |
130 | int err; | 130 | int err; |
131 | 131 | ||
132 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) | 132 | for_each_cmsghdr(cmsg, msg) { |
133 | { | ||
134 | err = -EINVAL; | 133 | err = -EINVAL; |
135 | 134 | ||
136 | /* Verify that cmsg_len is at least sizeof(struct cmsghdr) */ | 135 | /* Verify that cmsg_len is at least sizeof(struct cmsghdr) */ |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 19f038739087..e171b780b499 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -703,7 +703,7 @@ EXPORT_SYMBOL_GPL(compat_dccp_getsockopt); | |||
703 | 703 | ||
704 | static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb) | 704 | static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb) |
705 | { | 705 | { |
706 | struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg); | 706 | struct cmsghdr *cmsg; |
707 | 707 | ||
708 | /* | 708 | /* |
709 | * Assign an (opaque) qpolicy priority value to skb->priority. | 709 | * Assign an (opaque) qpolicy priority value to skb->priority. |
@@ -717,8 +717,7 @@ static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb) | |||
717 | */ | 717 | */ |
718 | skb->priority = 0; | 718 | skb->priority = 0; |
719 | 719 | ||
720 | for (; cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) { | 720 | for_each_cmsghdr(cmsg, msg) { |
721 | |||
722 | if (!CMSG_OK(msg, cmsg)) | 721 | if (!CMSG_OK(msg, cmsg)) |
723 | return -EINVAL; | 722 | return -EINVAL; |
724 | 723 | ||
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 640f26c6a9fe..8a89c738b7a3 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -192,7 +192,7 @@ int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc, | |||
192 | int err, val; | 192 | int err, val; |
193 | struct cmsghdr *cmsg; | 193 | struct cmsghdr *cmsg; |
194 | 194 | ||
195 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { | 195 | for_each_cmsghdr(cmsg, msg) { |
196 | if (!CMSG_OK(msg, cmsg)) | 196 | if (!CMSG_OK(msg, cmsg)) |
197 | return -EINVAL; | 197 | return -EINVAL; |
198 | #if IS_ENABLED(CONFIG_IPV6) | 198 | #if IS_ENABLED(CONFIG_IPV6) |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 2464a00e36ab..100c589a2a6c 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -657,7 +657,7 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk, | |||
657 | int len; | 657 | int len; |
658 | int err = 0; | 658 | int err = 0; |
659 | 659 | ||
660 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { | 660 | for_each_cmsghdr(cmsg, msg) { |
661 | int addr_type; | 661 | int addr_type; |
662 | 662 | ||
663 | if (!CMSG_OK(msg, cmsg)) { | 663 | if (!CMSG_OK(msg, cmsg)) { |
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 1cd3f8107239..2e9953b2db84 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
@@ -1070,9 +1070,7 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1070 | txmsg.class = 0; | 1070 | txmsg.class = 0; |
1071 | 1071 | ||
1072 | /* iterate over control messages */ | 1072 | /* iterate over control messages */ |
1073 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; | 1073 | for_each_cmsghdr(cmsg, msg) { |
1074 | cmsg = CMSG_NXTHDR(msg, cmsg)) { | ||
1075 | |||
1076 | if (!CMSG_OK(msg, cmsg)) { | 1074 | if (!CMSG_OK(msg, cmsg)) { |
1077 | err = -EINVAL; | 1075 | err = -EINVAL; |
1078 | goto out; | 1076 | goto out; |
diff --git a/net/rds/send.c b/net/rds/send.c index 40a5629a0a13..42f65d4305c8 100644 --- a/net/rds/send.c +++ b/net/rds/send.c | |||
@@ -826,7 +826,7 @@ static int rds_rm_size(struct msghdr *msg, int data_len) | |||
826 | int cmsg_groups = 0; | 826 | int cmsg_groups = 0; |
827 | int retval; | 827 | int retval; |
828 | 828 | ||
829 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { | 829 | for_each_cmsghdr(cmsg, msg) { |
830 | if (!CMSG_OK(msg, cmsg)) | 830 | if (!CMSG_OK(msg, cmsg)) |
831 | return -EINVAL; | 831 | return -EINVAL; |
832 | 832 | ||
@@ -878,7 +878,7 @@ static int rds_cmsg_send(struct rds_sock *rs, struct rds_message *rm, | |||
878 | struct cmsghdr *cmsg; | 878 | struct cmsghdr *cmsg; |
879 | int ret = 0; | 879 | int ret = 0; |
880 | 880 | ||
881 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { | 881 | for_each_cmsghdr(cmsg, msg) { |
882 | if (!CMSG_OK(msg, cmsg)) | 882 | if (!CMSG_OK(msg, cmsg)) |
883 | return -EINVAL; | 883 | return -EINVAL; |
884 | 884 | ||
diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c index 86e0f10aa2c0..e1a9373e5979 100644 --- a/net/rxrpc/ar-output.c +++ b/net/rxrpc/ar-output.c | |||
@@ -45,7 +45,7 @@ static int rxrpc_sendmsg_cmsg(struct rxrpc_sock *rx, struct msghdr *msg, | |||
45 | if (msg->msg_controllen == 0) | 45 | if (msg->msg_controllen == 0) |
46 | return -EINVAL; | 46 | return -EINVAL; |
47 | 47 | ||
48 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { | 48 | for_each_cmsghdr(cmsg, msg) { |
49 | if (!CMSG_OK(msg, cmsg)) | 49 | if (!CMSG_OK(msg, cmsg)) |
50 | return -EINVAL; | 50 | return -EINVAL; |
51 | 51 | ||
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index c92f96cda699..2625eccb77d5 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -6592,8 +6592,7 @@ static int sctp_msghdr_parse(const struct msghdr *msg, sctp_cmsgs_t *cmsgs) | |||
6592 | struct cmsghdr *cmsg; | 6592 | struct cmsghdr *cmsg; |
6593 | struct msghdr *my_msg = (struct msghdr *)msg; | 6593 | struct msghdr *my_msg = (struct msghdr *)msg; |
6594 | 6594 | ||
6595 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; | 6595 | for_each_cmsghdr(cmsg, my_msg) { |
6596 | cmsg = CMSG_NXTHDR(my_msg, cmsg)) { | ||
6597 | if (!CMSG_OK(my_msg, cmsg)) | 6596 | if (!CMSG_OK(my_msg, cmsg)) |
6598 | return -EINVAL; | 6597 | return -EINVAL; |
6599 | 6598 | ||