From patchwork Thu Oct 27 15:08:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9399701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF3566057E for ; Thu, 27 Oct 2016 15:09:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAC2D2A334 for ; Thu, 27 Oct 2016 15:09:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE7072A33B; Thu, 27 Oct 2016 15:09:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B21422A335 for ; Thu, 27 Oct 2016 15:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941789AbcJ0PJM (ORCPT ); Thu, 27 Oct 2016 11:09:12 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:53947 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934883AbcJ0PJL (ORCPT ); Thu, 27 Oct 2016 11:09:11 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue005) with ESMTPA (Nemesis) id 0MMJjd-1byvtP3c2X-0084Jx; Thu, 27 Oct 2016 17:08:50 +0200 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , Hans Verkuil , Jarod Wilson , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] [media] dvb: avoid warning in dvb_net Date: Thu, 27 Oct 2016 17:08:34 +0200 Message-Id: <20161027150848.3623829-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:0sB7sAyJyRdg995kHYdVCtYkrfSEramWZWRAH5YKnXZfBLY0rgF +WAQKXPwvdnUnhV6ExbnD6to6Hixp/Jm+pHP24KP9evHCxuv8HczrJPKOQ+6GZSn9XSkI06 gfiYKrkd2+/YJJ4t3vBD0PGMeuzGsYcg96d0+GO44tqX2KqQ7nKetmwiMX7K39QC02N8Hl4 YNntJ27amE7E/N+Pvilhw== X-UI-Out-Filterresults: notjunk:1; V01:K0:XRIT8LdOXug=:BjpM0+oQMV6u5z0qZySjuk K+g3nmAPvLQS0uXDUq8qY0VCw3DOinUj80moUwuIWT5kERJWTE19hR+/aIbyUeGjEuMvnEdJi KIxwOXnAoJ8QQcgI+ZvjdMDD0ZZClXKPzNwG0rfHZ9ofZYKp36355tLx0djizhuIFeEBJgxc9 SFGt1tnXRqatQjJtIHrgB14eIA2sCxr2rnWx/QPn/ZzCrS+684NrQmpSBrr4ACkjyJYCErYcY 8jH0ARkMN1odqMYvwt8kWFnrA3MpfCJk8BcL4WoHrqAwKhl4Xf9aNBE9HpSkMaFE4SSvwYuTS Cclwz4HjbZ4uKFbULRhypcJlDZBRSn/XzPZzHV9UyJrgQHcaiNv+FCO2GVuPBh2lrzeNNg66B AkCDWD8sCT5polAb9hFrn4g8mIT0uF7Zxx+HDmv7st/UXRnaDEyIyqkjo02JYbNpRvg/jcqPY ZxQdCJm+INixLqceT/NDPaSoOfpuFekSQvhLnegPQ1tzlQTViWnY7oRW4wULaOGNk4fs+o4hY BIM72YHqyEVxTK+qmLaXo++D9R2A8vWtZSqrXMyOSdQZDSAiugwtQohebUPhnDhj7cUuMeSsQ ZMPBT/roRObC24gr+ls+H4qefS6go757/xoLrlxPmoWSHqH7n9bFS4FElpiy3jzcVQIva/kXK NGjz1JWsA0D8H9d6tY8kjcsLhyZD5CRYiQmHOK4oflKvOy1q8r3jxfolRf/FYuB4et6IjBIzs IMa2P9SX9tgYsV9Q Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With gcc-5 or higher on x86, we can get a bogus warning in the dvb-net code: drivers/media/dvb-core/dvb_net.c: In function ‘dvb_net_ule’: arch/x86/include/asm/string_32.h:77:14: error: ‘dest_addr’ may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/media/dvb-core/dvb_net.c:633:8: note: ‘dest_addr’ was declared here The problem here is that gcc doesn't track all of the conditions to prove it can't end up copying uninitialized data. This changes the logic around so we zero out the destination address earlier when we determine that it is not set here. This allows the compiler to figure it out. Signed-off-by: Arnd Bergmann --- v2: fix typo pointed out by Jarod Wilson drivers/media/dvb-core/dvb_net.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c index 088914c4623f..c32156426463 100644 --- a/drivers/media/dvb-core/dvb_net.c +++ b/drivers/media/dvb-core/dvb_net.c @@ -688,6 +688,9 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) ETH_ALEN); skb_pull(priv->ule_skb, ETH_ALEN); } + } else { + /* otherwise use zero destination address */ + eth_zero_addr(dest_addr); } /* Handle ULE Extension Headers. */ @@ -715,13 +718,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) if (!priv->ule_bridged) { skb_push(priv->ule_skb, ETH_HLEN); ethh = (struct ethhdr *)priv->ule_skb->data; - if (!priv->ule_dbit) { - /* dest_addr buffer is only valid if priv->ule_dbit == 0 */ - memcpy(ethh->h_dest, dest_addr, ETH_ALEN); - eth_zero_addr(ethh->h_source); - } - else /* zeroize source and dest */ - memset( ethh, 0, ETH_ALEN*2 ); + memcpy(ethh->h_dest, dest_addr, ETH_ALEN); + eth_zero_addr(ethh->h_source); ethh->h_proto = htons(priv->ule_sndu_type); }