netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf-next] ipvs: fix uninitialized variable warning
@ 2020-03-30  3:20 Haishuang Yan
  2020-03-30  7:11 ` Julian Anastasov
  0 siblings, 1 reply; 2+ messages in thread
From: Haishuang Yan @ 2020-03-30  3:20 UTC (permalink / raw)
  To: Simon Horman, Julian Anastasov, Pablo Neira Ayuso
  Cc: netdev, lvs-devel, netfilter-devel, linux-kernel, Haishuang Yan

If outer_proto is not set, GCC warning as following:

In file included from net/netfilter/ipvs/ip_vs_core.c:52:
net/netfilter/ipvs/ip_vs_core.c: In function 'ip_vs_in_icmp':
include/net/ip_vs.h:233:4: warning: 'outer_proto' may be used uninitialized in this function [-Wmaybe-uninitialized]
 233 |    printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \
     |    ^~~~~~
net/netfilter/ipvs/ip_vs_core.c:1666:8: note: 'outer_proto' was declared here
1666 |  char *outer_proto;
     |        ^~~~~~~~~~~

Fixes: 73348fed35d0 ("ipvs: optimize tunnel dumps for icmp errors")
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/netfilter/ipvs/ip_vs_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index d2ac530..aa6a603 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1663,7 +1663,7 @@ static int ipvs_gre_decap(struct netns_ipvs *ipvs, struct sk_buff *skb,
 	unsigned int offset, offset2, ihl, verdict;
 	bool tunnel, new_cp = false;
 	union nf_inet_addr *raddr;
-	char *outer_proto;
+	char *outer_proto = "IPIP";
 
 	*related = 1;
 
@@ -1723,7 +1723,6 @@ static int ipvs_gre_decap(struct netns_ipvs *ipvs, struct sk_buff *skb,
 		if (cih == NULL)
 			return NF_ACCEPT; /* The packet looks wrong, ignore */
 		tunnel = true;
-		outer_proto = "IPIP";
 	} else if ((cih->protocol == IPPROTO_UDP ||	/* Can be UDP encap */
 		    cih->protocol == IPPROTO_GRE) &&	/* Can be GRE encap */
 		   /* Error for our tunnel must arrive at LOCAL_IN */
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH nf-next] ipvs: fix uninitialized variable warning
  2020-03-30  3:20 [PATCH nf-next] ipvs: fix uninitialized variable warning Haishuang Yan
@ 2020-03-30  7:11 ` Julian Anastasov
  0 siblings, 0 replies; 2+ messages in thread
From: Julian Anastasov @ 2020-03-30  7:11 UTC (permalink / raw)
  To: Haishuang Yan
  Cc: Simon Horman, Pablo Neira Ayuso, netdev, lvs-devel,
	netfilter-devel, linux-kernel


	Hello,

On Mon, 30 Mar 2020, Haishuang Yan wrote:

> If outer_proto is not set, GCC warning as following:
> 
> In file included from net/netfilter/ipvs/ip_vs_core.c:52:
> net/netfilter/ipvs/ip_vs_core.c: In function 'ip_vs_in_icmp':
> include/net/ip_vs.h:233:4: warning: 'outer_proto' may be used uninitialized in this function [-Wmaybe-uninitialized]
>  233 |    printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \
>      |    ^~~~~~
> net/netfilter/ipvs/ip_vs_core.c:1666:8: note: 'outer_proto' was declared here
> 1666 |  char *outer_proto;
>      |        ^~~~~~~~~~~
> 
> Fixes: 73348fed35d0 ("ipvs: optimize tunnel dumps for icmp errors")
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

Acked-by: Julian Anastasov <ja@ssi.bg>

	Hm, my compiler does not report it: gcc version 9.1.1

> ---
>  net/netfilter/ipvs/ip_vs_core.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
> index d2ac530..aa6a603 100644
> --- a/net/netfilter/ipvs/ip_vs_core.c
> +++ b/net/netfilter/ipvs/ip_vs_core.c
> @@ -1663,7 +1663,7 @@ static int ipvs_gre_decap(struct netns_ipvs *ipvs, struct sk_buff *skb,
>  	unsigned int offset, offset2, ihl, verdict;
>  	bool tunnel, new_cp = false;
>  	union nf_inet_addr *raddr;
> -	char *outer_proto;
> +	char *outer_proto = "IPIP";
>  
>  	*related = 1;
>  
> @@ -1723,7 +1723,6 @@ static int ipvs_gre_decap(struct netns_ipvs *ipvs, struct sk_buff *skb,
>  		if (cih == NULL)
>  			return NF_ACCEPT; /* The packet looks wrong, ignore */
>  		tunnel = true;
> -		outer_proto = "IPIP";
>  	} else if ((cih->protocol == IPPROTO_UDP ||	/* Can be UDP encap */
>  		    cih->protocol == IPPROTO_GRE) &&	/* Can be GRE encap */
>  		   /* Error for our tunnel must arrive at LOCAL_IN */
> -- 
> 1.8.3.1

Regards

--
Julian Anastasov <ja@ssi.bg>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-30  7:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30  3:20 [PATCH nf-next] ipvs: fix uninitialized variable warning Haishuang Yan
2020-03-30  7:11 ` Julian Anastasov

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).