Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965387AbcJXUWn (ORCPT ); Mon, 24 Oct 2016 16:22:43 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:53268 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965285AbcJXUWi (ORCPT ); Mon, 24 Oct 2016 16:22:38 -0400 From: Arnd Bergmann To: Julian Anastasov Cc: Wensong Zhang , Simon Horman , Pablo Neira Ayuso , Patrick McHardy , Jozsef Kadlecsik , "David S. Miller" , Quentin Armitage , netdev@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] netfilter: ip_vs_sync: fix bogus maybe-uninitialized warning Date: Mon, 24 Oct 2016 22:21:59 +0200 Message-ID: <12460209.DFK3VxnryE@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <20161024153454.2766113-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:gdpUJbFqrIJiD6ybHl3wkCvju0Qi1R9XJWOcZtvi/L6b3oKkIN7 UAkIGI+FYYv51w0Hapik1EIowi60ZURJVmm0WvtKB4nG5i9miIdHj+RJ7wCWwq8faqxabl3 HYpcavEh+aaiIDJKixCdQ2WKpdDRoZqTqnoAX3fwnp10mnw1+tZo0iVBo/eoZsiOAqcGjd4 UbOxL41/jTc8djeC0y9pQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:IDWejHF//68=:hiq9Mm1o1X5FmDuwvKOuXt PloVlM/Dl3qjYH6+Oi8GQrLJWuZsFUNR7lG5dvRYaUU48dn4ir3PyjxfPuQMzZZFSSvf0fmFD 4immmCUON+HDKe3GFjS4wyQjags6D2Exn4a2hlxdcXrEiemxi+VvtYnXT7u+dRlisJVLkPPeE depRW7SFTJjER6jtmtK+seV7oCuTa3MJYHqVa8s+bWju/44x/Bw1iAXyFuq22fM3MD3JUQ81R R8hQdS33lMf6ovJooj9aez7Miav0X8hWvmwwQS0Iu3mzJ1TeaDsxsnIrFqBBasJhOHQzarfTH GvgN7tCunQ27uutw/zJLfq0hBDnVq+OjNtjvNaGJ55LzFCcy0ua6TWzAgAHIYZXJdolYcjO9D pg8b/Xta/EYxP/+tSkLus/takAeNp0auizEiOCONYbIH7EIWpCb/Yl10jvtoVzQ945lOAOAII umlDZnDfBP3lbng1Ge+pa9fxLpBquqFbOUcGcxLbh8XKD2FccyRHjOmAIbac32up70ftA+xvR lz6hFbQF+eeGYhvK/iPCQ+0YsCdPBkPs1rxAFFP+YbxOI1Kmx5sGenpCQzaWvp3ahPY5Ze7mn DksbaakYZjkANKcZ6dwDP5t71owgqVpusDSLj8s+6NgHelfCxBuAOaDCxCGEcsEqADE0R8p7s 6CKs+gk9d2pOvmtKrtVFcHm1DJ6TVdcmtge4204iUAPwOXUOH9ylGT6d/rxoXeRQMyZUmYi2+ 77rVYmlJ4JfysTGj Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2078 Lines: 58 On Monday, October 24, 2016 10:47:54 PM CEST Julian Anastasov wrote: > > diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c > > index 1b07578bedf3..9350530c16c1 100644 > > --- a/net/netfilter/ipvs/ip_vs_sync.c > > +++ b/net/netfilter/ipvs/ip_vs_sync.c > > @@ -283,6 +283,7 @@ struct ip_vs_sync_buff { > > */ > > static void ntoh_seq(struct ip_vs_seq *no, struct ip_vs_seq *ho) > > { > > + memset(ho, 0, sizeof(*ho)); > > ho->init_seq = get_unaligned_be32(&no->init_seq); > > ho->delta = get_unaligned_be32(&no->delta); > > ho->previous_delta = get_unaligned_be32(&no->previous_delta); > > So, now there is a double write here? Correct. I would hope that a sane version of gcc would just not perform the first write. What happens instead is that the version that produces the warning here moves the initialization to the top of the calling function. > What about such constructs?: > > *ho = (struct ip_vs_seq) { > .init_seq = get_unaligned_be32(&no->init_seq), > ... > }; > > Any difference in the compiled code or warnings? Yes, it's one of many things I tried. What happens here is that the warning remains as long as all fields are initialized together, e.g. these two produces the same warning: a) ho->init_seq = get_unaligned_be32(&no->init_seq); ho->delta = get_unaligned_be32(&no->delta); ho->previous_delta = get_unaligned_be32(&no->previous_delta); b) *ho = (struct ip_vs_seq) { .init_seq = get_unaligned_be32(&no->init_seq); .delta = get_unaligned_be32(&no->delta); .previous_delta = get_unaligned_be32(&no->previous_delta); }; but this one does not: c) *ho = (struct ip_vs_seq) { .delta = get_unaligned_be32(&no->delta); .previous_delta = get_unaligned_be32(&no->previous_delta); }; ho->init_seq = get_unaligned_be32(&no->init_seq); I have absolutely no idea what is going on inside of gcc here. Arnd