Re: [RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR
From: Gu Zheng Date: Fri, 5 Dec 2014 16:29:07 +0800 > Hi Joe, > Thanks for your comment. > On 12/05/2014 04:02 PM, Joe Perches wrote: > >> On Fri, 2014-12-05 at 15:14 +0800, Gu Zheng wrote: >>> Introduce helper macra >> >> macro > > Ah~, it's a typo. > >> >>> CMSG_FOREACH_HDR as a wrapper of the enumerating >>> cmsghdr from msghdr, just cleanup. >> >> maybe better to use lower case "for_each_cmsg_hdr" >> or some such. > > But this will make it out of the ordinary, as the existed ones > are all upper. > > David, what's your opinion? I think lowercase looks much better. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR
From: Gu Zheng guz.f...@cn.fujitsu.com Date: Fri, 5 Dec 2014 16:29:07 +0800 Hi Joe, Thanks for your comment. On 12/05/2014 04:02 PM, Joe Perches wrote: On Fri, 2014-12-05 at 15:14 +0800, Gu Zheng wrote: Introduce helper macra macro Ah~, it's a typo. CMSG_FOREACH_HDR as a wrapper of the enumerating cmsghdr from msghdr, just cleanup. maybe better to use lower case for_each_cmsg_hdr or some such. But this will make it out of the ordinary, as the existed ones are all upper. David, what's your opinion? I think lowercase looks much better. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR
Hi Joe, Thanks for your comment. On 12/05/2014 04:02 PM, Joe Perches wrote: > On Fri, 2014-12-05 at 15:14 +0800, Gu Zheng wrote: >> Introduce helper macra > > macro Ah~, it's a typo. > >> CMSG_FOREACH_HDR as a wrapper of the enumerating >> cmsghdr from msghdr, just cleanup. > > maybe better to use lower case "for_each_cmsg_hdr" > or some such. But this will make it out of the ordinary, as the existed ones are all upper. David, what's your opinion? Regards, Gu > > checkpatch would recognize that too as long as it > uses "for_each". > >> diff --git a/include/linux/socket.h b/include/linux/socket.h > [] >> @@ -94,6 +94,10 @@ struct cmsghdr { >> (cmsg)->cmsg_len <= (unsigned long) \ >> ((mhdr)->msg_controllen - \ >>((char *)(cmsg) - (char *)(mhdr)->msg_control))) >> +#define CMSG_FOREACH_HDR(cmsg, msg) \ >> +for (cmsg = CMSG_FIRSTHDR(msg); \ >> + cmsg; \ >> + cmsg = CMSG_NXTHDR(msg, cmsg)) > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR
On Fri, 2014-12-05 at 15:14 +0800, Gu Zheng wrote: > Introduce helper macra macro > CMSG_FOREACH_HDR as a wrapper of the enumerating > cmsghdr from msghdr, just cleanup. maybe better to use lower case "for_each_cmsg_hdr" or some such. checkpatch would recognize that too as long as it uses "for_each". > diff --git a/include/linux/socket.h b/include/linux/socket.h [] > @@ -94,6 +94,10 @@ struct cmsghdr { >(cmsg)->cmsg_len <= (unsigned long) \ >((mhdr)->msg_controllen - \ > ((char *)(cmsg) - (char *)(mhdr)->msg_control))) > +#define CMSG_FOREACH_HDR(cmsg, msg) \ > + for (cmsg = CMSG_FIRSTHDR(msg); \ > + cmsg; \ > + cmsg = CMSG_NXTHDR(msg, cmsg)) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR
On Fri, 2014-12-05 at 15:14 +0800, Gu Zheng wrote: Introduce helper macra macro CMSG_FOREACH_HDR as a wrapper of the enumerating cmsghdr from msghdr, just cleanup. maybe better to use lower case for_each_cmsg_hdr or some such. checkpatch would recognize that too as long as it uses for_each. diff --git a/include/linux/socket.h b/include/linux/socket.h [] @@ -94,6 +94,10 @@ struct cmsghdr { (cmsg)-cmsg_len = (unsigned long) \ ((mhdr)-msg_controllen - \ ((char *)(cmsg) - (char *)(mhdr)-msg_control))) +#define CMSG_FOREACH_HDR(cmsg, msg) \ + for (cmsg = CMSG_FIRSTHDR(msg); \ + cmsg; \ + cmsg = CMSG_NXTHDR(msg, cmsg)) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR
Hi Joe, Thanks for your comment. On 12/05/2014 04:02 PM, Joe Perches wrote: On Fri, 2014-12-05 at 15:14 +0800, Gu Zheng wrote: Introduce helper macra macro Ah~, it's a typo. CMSG_FOREACH_HDR as a wrapper of the enumerating cmsghdr from msghdr, just cleanup. maybe better to use lower case for_each_cmsg_hdr or some such. But this will make it out of the ordinary, as the existed ones are all upper. David, what's your opinion? Regards, Gu checkpatch would recognize that too as long as it uses for_each. diff --git a/include/linux/socket.h b/include/linux/socket.h [] @@ -94,6 +94,10 @@ struct cmsghdr { (cmsg)-cmsg_len = (unsigned long) \ ((mhdr)-msg_controllen - \ ((char *)(cmsg) - (char *)(mhdr)-msg_control))) +#define CMSG_FOREACH_HDR(cmsg, msg) \ +for (cmsg = CMSG_FIRSTHDR(msg); \ + cmsg; \ + cmsg = CMSG_NXTHDR(msg, cmsg)) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR
Introduce helper macra CMSG_FOREACH_HDR as a wrapper of the enumerating cmsghdr from msghdr, just cleanup. Signed-off-by: Gu Zheng --- .../networking/timestamping/timestamping.c |4 +--- .../networking/timestamping/txtimestamp.c |4 +--- crypto/af_alg.c|2 +- include/linux/socket.h |4 net/core/scm.c |3 +-- net/dccp/proto.c |5 ++--- net/ipv4/ip_sockglue.c |2 +- net/ipv6/datagram.c|2 +- net/iucv/af_iucv.c |4 +--- net/rds/send.c |4 ++-- net/rxrpc/ar-output.c |2 +- net/sctp/socket.c |3 +-- 12 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Documentation/networking/timestamping/timestamping.c b/Documentation/networking/timestamping/timestamping.c index 5cdfd74..3106e88 100644 --- a/Documentation/networking/timestamping/timestamping.c +++ b/Documentation/networking/timestamping/timestamping.c @@ -169,9 +169,7 @@ static void printpacket(struct msghdr *msg, int res, res, inet_ntoa(from_addr->sin_addr), msg->msg_controllen); - for (cmsg = CMSG_FIRSTHDR(msg); -cmsg; -cmsg = CMSG_NXTHDR(msg, cmsg)) { + CMSG_FOREACH_HDR(cmsg, msg) { printf(" cmsg len %zu: ", cmsg->cmsg_len); switch (cmsg->cmsg_level) { case SOL_SOCKET: diff --git a/Documentation/networking/timestamping/txtimestamp.c b/Documentation/networking/timestamping/txtimestamp.c index b32fc2a..e44ef35 100644 --- a/Documentation/networking/timestamping/txtimestamp.c +++ b/Documentation/networking/timestamping/txtimestamp.c @@ -149,9 +149,7 @@ static void __recv_errmsg_cmsg(struct msghdr *msg, int payload_len) struct scm_timestamping *tss = NULL; struct cmsghdr *cm; - for (cm = CMSG_FIRSTHDR(msg); -cm && cm->cmsg_len; -cm = CMSG_NXTHDR(msg, cm)) { + CMSG_FOREACH_HDR(cmsg, msg) { if (cm->cmsg_level == SOL_SOCKET && cm->cmsg_type == SCM_TIMESTAMPING) { tss = (void *) CMSG_DATA(cm); diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 6a3ad80..3df7d53 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -399,7 +399,7 @@ int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con) { struct cmsghdr *cmsg; - for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { + CMSG_FOREACH_HDR(cmsg, msg) { if (!CMSG_OK(msg, cmsg)) return -EINVAL; if (cmsg->cmsg_level != SOL_ALG) diff --git a/include/linux/socket.h b/include/linux/socket.h index bb9b836..d4b592f 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -94,6 +94,10 @@ struct cmsghdr { (cmsg)->cmsg_len <= (unsigned long) \ ((mhdr)->msg_controllen - \ ((char *)(cmsg) - (char *)(mhdr)->msg_control))) +#define CMSG_FOREACH_HDR(cmsg, msg) \ + for (cmsg = CMSG_FIRSTHDR(msg); \ +cmsg; \ +cmsg = CMSG_NXTHDR(msg, cmsg)) /* * Get the next cmsg header diff --git a/net/core/scm.c b/net/core/scm.c index b442e7e..e938c49 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) struct cmsghdr *cmsg; int err; - for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) - { + CMSG_FOREACH_HDR(cmsg, msg) { err = -EINVAL; /* Verify that cmsg_len is at least sizeof(struct cmsghdr) */ diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 5ab6627..d449cc5 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -703,7 +703,7 @@ EXPORT_SYMBOL_GPL(compat_dccp_getsockopt); static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb) { - struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg); + struct cmsghdr *cmsg; /* * 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) */ skb->priority = 0; - for (; cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) { - + CMSG_FOREACH_HDR(cmsg, msg) { if (!CMSG_OK(msg, cmsg)) return -EINVAL; diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 9daf217..14a6f71 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, int
[RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR
Introduce helper macra CMSG_FOREACH_HDR as a wrapper of the enumerating cmsghdr from msghdr, just cleanup. Signed-off-by: Gu Zheng guz.f...@cn.fujitsu.com --- .../networking/timestamping/timestamping.c |4 +--- .../networking/timestamping/txtimestamp.c |4 +--- crypto/af_alg.c|2 +- include/linux/socket.h |4 net/core/scm.c |3 +-- net/dccp/proto.c |5 ++--- net/ipv4/ip_sockglue.c |2 +- net/ipv6/datagram.c|2 +- net/iucv/af_iucv.c |4 +--- net/rds/send.c |4 ++-- net/rxrpc/ar-output.c |2 +- net/sctp/socket.c |3 +-- 12 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Documentation/networking/timestamping/timestamping.c b/Documentation/networking/timestamping/timestamping.c index 5cdfd74..3106e88 100644 --- a/Documentation/networking/timestamping/timestamping.c +++ b/Documentation/networking/timestamping/timestamping.c @@ -169,9 +169,7 @@ static void printpacket(struct msghdr *msg, int res, res, inet_ntoa(from_addr-sin_addr), msg-msg_controllen); - for (cmsg = CMSG_FIRSTHDR(msg); -cmsg; -cmsg = CMSG_NXTHDR(msg, cmsg)) { + CMSG_FOREACH_HDR(cmsg, msg) { printf( cmsg len %zu: , cmsg-cmsg_len); switch (cmsg-cmsg_level) { case SOL_SOCKET: diff --git a/Documentation/networking/timestamping/txtimestamp.c b/Documentation/networking/timestamping/txtimestamp.c index b32fc2a..e44ef35 100644 --- a/Documentation/networking/timestamping/txtimestamp.c +++ b/Documentation/networking/timestamping/txtimestamp.c @@ -149,9 +149,7 @@ static void __recv_errmsg_cmsg(struct msghdr *msg, int payload_len) struct scm_timestamping *tss = NULL; struct cmsghdr *cm; - for (cm = CMSG_FIRSTHDR(msg); -cm cm-cmsg_len; -cm = CMSG_NXTHDR(msg, cm)) { + CMSG_FOREACH_HDR(cmsg, msg) { if (cm-cmsg_level == SOL_SOCKET cm-cmsg_type == SCM_TIMESTAMPING) { tss = (void *) CMSG_DATA(cm); diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 6a3ad80..3df7d53 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -399,7 +399,7 @@ int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con) { struct cmsghdr *cmsg; - for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { + CMSG_FOREACH_HDR(cmsg, msg) { if (!CMSG_OK(msg, cmsg)) return -EINVAL; if (cmsg-cmsg_level != SOL_ALG) diff --git a/include/linux/socket.h b/include/linux/socket.h index bb9b836..d4b592f 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -94,6 +94,10 @@ struct cmsghdr { (cmsg)-cmsg_len = (unsigned long) \ ((mhdr)-msg_controllen - \ ((char *)(cmsg) - (char *)(mhdr)-msg_control))) +#define CMSG_FOREACH_HDR(cmsg, msg) \ + for (cmsg = CMSG_FIRSTHDR(msg); \ +cmsg; \ +cmsg = CMSG_NXTHDR(msg, cmsg)) /* * Get the next cmsg header diff --git a/net/core/scm.c b/net/core/scm.c index b442e7e..e938c49 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) struct cmsghdr *cmsg; int err; - for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) - { + CMSG_FOREACH_HDR(cmsg, msg) { err = -EINVAL; /* Verify that cmsg_len is at least sizeof(struct cmsghdr) */ diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 5ab6627..d449cc5 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -703,7 +703,7 @@ EXPORT_SYMBOL_GPL(compat_dccp_getsockopt); static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb) { - struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg); + struct cmsghdr *cmsg; /* * 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) */ skb-priority = 0; - for (; cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) { - + CMSG_FOREACH_HDR(cmsg, msg) { if (!CMSG_OK(msg, cmsg)) return -EINVAL; diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 9daf217..14a6f71 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,
Re: [PATCH] net: introduce helper macra CMSG_FOREACH_HDR
Hi David, On 11/24/2014 01:55 PM, David Miller wrote: > > Your postings do not make it to the mailing list, in fact they don't > even make it to the list server itself. Thanks for your reminder. > > Generally speaking, sites in China have this problem off and on, and > in unpredictable ways. Seems we should say thanks to GFW... > > You need to sort this out because I will not apply patches that don't > hit the mailing list for review. I'll confirm it first, and resent the patches once the problem is gone. Regards, Gu > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] net: introduce helper macra CMSG_FOREACH_HDR
Your postings do not make it to the mailing list, in fact they don't even make it to the list server itself. Generally speaking, sites in China have this problem off and on, and in unpredictable ways. You need to sort this out because I will not apply patches that don't hit the mailing list for review. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] net: introduce helper macra CMSG_FOREACH_HDR
Your postings do not make it to the mailing list, in fact they don't even make it to the list server itself. Generally speaking, sites in China have this problem off and on, and in unpredictable ways. You need to sort this out because I will not apply patches that don't hit the mailing list for review. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] net: introduce helper macra CMSG_FOREACH_HDR
Hi David, On 11/24/2014 01:55 PM, David Miller wrote: Your postings do not make it to the mailing list, in fact they don't even make it to the list server itself. Thanks for your reminder. Generally speaking, sites in China have this problem off and on, and in unpredictable ways. Seems we should say thanks to GFW... You need to sort this out because I will not apply patches that don't hit the mailing list for review. I'll confirm it first, and resent the patches once the problem is gone. Regards, Gu -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/