From: Simon Horman <horms@verge.net.au>
To: Li Qiong <liqiong@nfschina.com>
Cc: Julian Anastasov <ja@ssi.bg>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org,
kernel-janitors@vger.kernel.org, coreteam@netfilter.org,
Yu Zhe <yuzhe@nfschina.com>
Subject: Re: [PATCH] ipvs: initialize 'ret' variable in do_ip_vs_set_ctl()
Date: Fri, 2 Dec 2022 11:02:04 +0100 [thread overview]
Message-ID: <Y4nNHHfIY7iEvMgr@vergenet.net> (raw)
In-Reply-To: <20221202032511.1435-1-liqiong@nfschina.com>
On Fri, Dec 02, 2022 at 11:25:11AM +0800, Li Qiong wrote:
> The 'ret' should need to be initialized to 0, in case
> return a uninitialized value because no default process
> for "switch (cmd)".
>
> Signed-off-by: Li Qiong <liqiong@nfschina.com>
Thanks,
I agree there seems to be a problem here. But perhaps it's nicer to solve
it by adding a default case to the switch statement?
Also, if we update the declaration of ret, perhaps we could also move it to
the bottom of the declaration of local variables, to move more towards
reverse xmas tree order.
But to be honest, I don't feel strongly about either of these issues.
So if someone wants to take this patch as-is then feel free to add.
Reviewed-by: Simon Horman <horms@verge.net.au>
> ---
> net/netfilter/ipvs/ip_vs_ctl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index 988222fff9f0..4b20db86077c 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -2456,7 +2456,7 @@ static int
> do_ip_vs_set_ctl(struct sock *sk, int cmd, sockptr_t ptr, unsigned int len)
> {
> struct net *net = sock_net(sk);
> - int ret;
> + int ret = 0;
> unsigned char arg[MAX_SET_ARGLEN];
> struct ip_vs_service_user *usvc_compat;
> struct ip_vs_service_user_kern usvc;
> --
> 2.11.0
>
next prev parent reply other threads:[~2022-12-02 10:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 3:25 [PATCH] ipvs: initialize 'ret' variable in do_ip_vs_set_ctl() Li Qiong
2022-12-02 10:02 ` Simon Horman [this message]
2022-12-02 10:07 ` Dan Carpenter
2022-12-02 10:18 ` liqiong
2022-12-02 10:26 ` Dan Carpenter
2022-12-02 11:26 ` Julian Anastasov
2022-12-12 7:05 ` liqiong
2022-12-12 7:43 ` [PATCH v2] ipvs: add a 'default' case " Li Qiong
2022-12-12 14:20 ` Julian Anastasov
2022-12-13 11:28 ` Pablo Neira Ayuso
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=Y4nNHHfIY7iEvMgr@vergenet.net \
--to=horms@verge.net.au \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=ja@ssi.bg \
--cc=kadlec@netfilter.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liqiong@nfschina.com \
--cc=lvs-devel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=yuzhe@nfschina.com \
/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