From patchwork Thu Mar 7 18:00:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10843599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A3D614DE for ; Thu, 7 Mar 2019 18:00:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 329332F412 for ; Thu, 7 Mar 2019 18:00:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 269B42F41C; Thu, 7 Mar 2019 18:00:50 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BEBA92F412 for ; Thu, 7 Mar 2019 18:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4eowuAsTvaRSWmuBdDEOV4zBvAIi6m+cuZd99KkgbzA=; b=GkdoyMR3tbXkxr TeHGe0phh0YSHV41Fj75m7qv5+E2IJ6Vdax2kilgypdKicahJpEn5TvivFZchcztM2QySR4BHonlz HspoVflPkNZm4JRWv6SU5SOy92cVqIMf3ZHYX31N+3UH0BUc153h7hxUHm0CdZ61pEqjKuXvCU0P9 C6uo5r9vbVhZCmNnAeyulpyhPe/j4V2b72A0MKME0d1yWmIsrHzGvKJ5fU5JkAqvJ9ET3Z1luSCNN 2T/OLHVuuTs6vZ27babC8C0FDu/iKYTyav4t5ju3RXjMRIjErrURezFM86aZi8JLZmoXGwmEPbVy+ O2EBLihE4apRAJrsaQHA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1xK4-0003nH-Bj; Thu, 07 Mar 2019 18:00:48 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1xK0-0003mt-GI for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2019 18:00:46 +0000 Received: by mail-ed1-x544.google.com with SMTP id a16so14261365edn.1 for ; Thu, 07 Mar 2019 10:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=80PbBrlLVjNDnkbdPPlTlo4rmy0Dx+45IEhmeAmWXDY=; b=Dsda7h2/CPiv7QuZI5alniBrtiXASBhNWAvKcJvTkeDUq9ApCSvAdQbyhj/LIoYcDH NGyX6Gn4IXl3liA9NaqG1zkN0QFtYkR+bswL6k+j6647CxuxS2Dy9b6AE3S349y7u0ej xr3FTpBYZy+d3yF2U5xa5xNHL16RikYISVh6taIKX3dmxVJzOkGQPUNZORNOfM2pvyEy bYefUPqdXllbr1xATwi1hYFO+q9GBAMkgCgnwWh1ZzqSzUc8CeAXb8mc4wz4qM5rSlRA THFAoDURYJ7A0PeYCIsx0sj4NEUeadvaUnO2i0pIes6Z5V0xfuK6UDQw2M4B618DrEEd 5b0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=80PbBrlLVjNDnkbdPPlTlo4rmy0Dx+45IEhmeAmWXDY=; b=pNzYI6BudCIvRJ8LzyBWj4QRAq+IYCNFbQOkgQ+fMz9KN8hAe7wJK3yb0chUaXlmlW a69qKMC0OsNtuNxmVKO9bMe5oxPh+wSHdD2dEUn7CMQYD+7dD4X9c6SlQ+aQX4IWwYH3 WXuwDurggBXGTXz9sDv0eEv42Z6Apzzf8Gqzkam7VRNBeuqGrtUT7LMCK3RrHveTgYmI rCp+5WdELYGB1UONpzu8sfIA7xnQgeR4KaihReJyZ8oX5EtQrw4iN14RrkYorE2dxUxV DxfiE7oXkNsXme7Q74tAS27PYb8t5sdePi+qxpHqQcp7nqeRjIbaGmsZJY3UALkPsyrl jmtQ== X-Gm-Message-State: APjAAAWxXWLu82qGGcslAyxkJ/0esYxjeJENOV8c+l4bt4i1UZBinZEQ RO/MLXnHn1yiBfc2PgUtzWc= X-Google-Smtp-Source: APXvYqzbxwDlNucMfu962ZRy3qrgQay23arYXt0G41hpmzMBTCKJoQi9biOatWyIGBRCQr/WQkJJ1w== X-Received: by 2002:a17:906:70d6:: with SMTP id g22mr8806152ejk.215.1551981642787; Thu, 07 Mar 2019 10:00:42 -0800 (PST) Received: from localhost.localdomain ([2a01:4f9:2a:1fae::2]) by smtp.gmail.com with ESMTPSA id y21sm1501108edb.54.2019.03.07.10.00.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 10:00:42 -0800 (PST) From: Nathan Chancellor To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" Subject: [PATCH v2] net: stmmac: Avoid sometimes uninitialized Clang warnings Date: Thu, 7 Mar 2019 11:00:28 -0700 Message-Id: <20190307180027.6226-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190307162101.29204-1-natechancellor@gmail.com> References: <20190307162101.29204-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190307_100044_543918_0F09A869 X-CRM114-Status: GOOD ( 14.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Maxime Coquelin , Nathan Chancellor , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When building with -Wsometimes-uninitialized, Clang warns: drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:495:3: warning: variable 'ns' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:495:3: warning: variable 'ns' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:532:3: warning: variable 'ns' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:532:3: warning: variable 'ns' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:741:3: warning: variable 'sec_inc' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:741:3: warning: variable 'sec_inc' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] Clang is concerned with the use of stmmac_do_void_callback (which stmmac_get_timestamp and stmmac_config_sub_second_increment wrap), as it may fail to initialize these values if the if condition was ever false (meaning the callbacks don't exist). It's not wrong because the callbacks (get_timestamp and config_sub_second_increment respectively) are the ones that initialize the variables. While it's unlikely that the callbacks are ever going to disappear and make that condition false, we can easily avoid this warning by zero initialize the variables. Link: https://github.com/ClangBuiltLinux/linux/issues/384 Suggested-by: Nick Desaulniers Reviewed-by: Nick Desaulniers Signed-off-by: Nathan Chancellor --- v1 -> v2: * Respect reverse Christmas tree variable ordering in stmmac_hwtstamp_set. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e2a13ec2e30b..97c5e1aad88f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -480,7 +480,7 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p, struct sk_buff *skb) { struct skb_shared_hwtstamps shhwtstamp; - u64 ns; + u64 ns = 0; if (!priv->hwts_tx_en) return; @@ -519,7 +519,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p, { struct skb_shared_hwtstamps *shhwtstamp = NULL; struct dma_desc *desc = p; - u64 ns; + u64 ns = 0; if (!priv->hwts_rx_en) return; @@ -564,8 +564,8 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) u32 snap_type_sel = 0; u32 ts_master_en = 0; u32 ts_event_en = 0; + u32 sec_inc = 0; u32 value = 0; - u32 sec_inc; bool xmac; xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;