From: Joe Perches <joe@perches.com>
To: yuan linyu <cugyly@163.com>, netdev@vger.kernel.org
Cc: "David S . Miller" <davem@davemloft.net>,
yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Subject: Re: [PATCH net-next v4] net: ipv6: fix code style error and warning of ndisc.c
Date: Sat, 20 May 2017 07:55:56 -0700 [thread overview]
Message-ID: <1495292156.2093.5.camel@perches.com> (raw)
In-Reply-To: <1495288650-17072-1-git-send-email-cugyly@163.com>
On Sat, 2017-05-20 at 21:57 +0800, yuan linyu wrote:
> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
[]
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
[]
> @@ -240,13 +240,15 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
> "%s: duplicated ND6 option found: type=%d\n",
> __func__, nd_opt->nd_opt_type);
> } else {
> - ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
> + ndopts->nd_opt_array[nd_opt->nd_opt_type] =
> + nd_opt;
> }
> break;
> case ND_OPT_PREFIX_INFO:
> ndopts->nd_opts_pi_end = nd_opt;
> if (!ndopts->nd_opt_array[nd_opt->nd_opt_type])
> - ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
> + ndopts->nd_opt_array[nd_opt->nd_opt_type] =
> + nd_opt;
> break;
> #ifdef CONFIG_IPV6_ROUTE_INFO
> case ND_OPT_ROUTE_INFO:
If you are going to do these 80 column line length changes,
(and they are not really useful or necessary here), perhaps
it'd be better to use a temporary to reduce the line length.
Something like:
---
net/ipv6/ndisc.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc41209a..a8521bc86795 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -234,20 +234,28 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
case ND_OPT_TARGET_LL_ADDR:
case ND_OPT_MTU:
case ND_OPT_NONCE:
- case ND_OPT_REDIRECT_HDR:
- if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
+ case ND_OPT_REDIRECT_HDR: {
+ struct nd_opt_hdr **hdr;
+
+ hdr = &ndopts->nd_opt_array[nd_opt->nd_opt_type];
+ if (*hdr) {
ND_PRINTK(2, warn,
"%s: duplicated ND6 option found: type=%d\n",
__func__, nd_opt->nd_opt_type);
} else {
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ *hdr = nd_opt;
}
break;
- case ND_OPT_PREFIX_INFO:
+ }
+ case ND_OPT_PREFIX_INFO: {
+ struct nd_opt_hdr **hdr;
+
+ hdr = &ndopts->nd_opt_array[nd_opt->nd_opt_type];
ndopts->nd_opts_pi_end = nd_opt;
- if (!ndopts->nd_opt_array[nd_opt->nd_opt_type])
- ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+ if (!*hdr)
+ *hdr = nd_opt;
break;
+ }
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
ndopts->nd_opts_ri_end = nd_opt;
prev parent reply other threads:[~2017-05-20 14:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-20 13:57 [PATCH net-next v4] net: ipv6: fix code style error and warning of ndisc.c yuan linyu
2017-05-20 14:55 ` Joe Perches [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=1495292156.2093.5.camel@perches.com \
--to=joe@perches.com \
--cc=Linyu.Yuan@alcatel-sbell.com.cn \
--cc=cugyly@163.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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