From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F017C43381 for ; Thu, 7 Mar 2019 18:13:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13D7520840 for ; Thu, 7 Mar 2019 18:13:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vbU/e/5/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726698AbfCGSNL (ORCPT ); Thu, 7 Mar 2019 13:13:11 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43687 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbfCGSNK (ORCPT ); Thu, 7 Mar 2019 13:13:10 -0500 Received: by mail-pf1-f196.google.com with SMTP id q17so12040623pfh.10 for ; Thu, 07 Mar 2019 10:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FQjfEuWWPGlxVOFdaO+RnpbsWJ3NkSCVY4/xY49b5ak=; b=vbU/e/5/QeXMXOrI1YPxmI+V3wYWcqXTo6pO4TAcik2KDwjFJdHAOd/sofaqpBmIG5 KYe7EgszOiawv4ZIlhHH8W19VuJg6E5VLU1xgIHq5whfPEOUF7HTUaw59bjWGdrD698G PGqz/Zm4g3JvtoXDQh5usNJ4uKCucoeHFRTW7Ii5EbRks++7HkNnpP7EtRkPhlhYZSaa b2UcqBLourfr480pqmYxlt/EIao2nzZ2nrH4ObL/YK08kg4A0MAUfJWNccpkUootMhH5 Sdbc0mIXvgXbhRbD8gnrI4IAImGj7qFvmcVRixGOdwbfqGheKLDoDMyBKk11ihvYBtEM n/Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FQjfEuWWPGlxVOFdaO+RnpbsWJ3NkSCVY4/xY49b5ak=; b=e6rDcLphUuxhO9qaKdxZ3Kzoevr+a/SxiDC0o+fIGIqKdfQSe858gDeyLGo5b0IiFR T6gZ5CdMah7L3fKmhZuB31SSS4jYTAcaigJ06aIZiWni3bO7zbx3HCpwdjSbxKD3ljCu +tYf4mHpEa+av6ieUkhfrH4IphUHjbdO+B4HlZq/CFO1iNc2BtdCVCZmbdRns8rFPv+u E+j6xnvHISz1AUWx0o78eyjOUAnIl7zHmgZWTpD3WDu+NfG+jZnujDz0xeuz+NaA341P r6AZtM+h9dOtX5LaG19hEmThCAYMhAYQPT6wpMBcqZeCwc47BIfNvsxt6LpefXCbZ03v GU3w== X-Gm-Message-State: APjAAAWUaWs3Dz6DHCSSUIxemVOAW3lPmKq7Wy3fKdGOjr49nC7Clcq1 jGB/LlV4rYSK482IPF/tZFjsQgpTNX8HNp41rD9NMw== X-Google-Smtp-Source: APXvYqzQ9NSuypziQqqFe860leXDVL3Xmy19jNxDyNv0Vkvoluj93Ot6fP+Nvqm5P5bbtps/wne847HtxGa5aIn/hn8= X-Received: by 2002:a63:40c1:: with SMTP id n184mr12006577pga.225.1551982389545; Thu, 07 Mar 2019 10:13:09 -0800 (PST) MIME-Version: 1.0 References: <20190307162101.29204-1-natechancellor@gmail.com> <20190307180027.6226-1-natechancellor@gmail.com> In-Reply-To: <20190307180027.6226-1-natechancellor@gmail.com> From: Nick Desaulniers Date: Thu, 7 Mar 2019 10:12:58 -0800 Message-ID: Subject: Re: [PATCH v2] net: stmmac: Avoid sometimes uninitialized Clang warnings To: Nathan Chancellor Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Linux ARM , LKML , clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 7, 2019 at 10:00 AM Nathan Chancellor wrote: > > 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 V2 LGTM, thanks for resending. > 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; > -- > 2.21.0 > > -- > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > To post to this group, send email to clang-built-linux@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20190307180027.6226-1-natechancellor%40gmail.com. > For more options, visit https://groups.google.com/d/optout. -- Thanks, ~Nick Desaulniers From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03213C43381 for ; Thu, 7 Mar 2019 18:13:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA88A20675 for ; Thu, 7 Mar 2019 18:13:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fhnfdy4w"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="vbU/e/5/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA88A20675 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OpnE8tPZpnlvHfsNWMOfNnkoal/uTbg94FhNouxS1ZM=; b=fhnfdy4wbh4D6F pPFBAK1pilz5uWFxava43UsKIdaCpLxZRL3CVOYMPbBVkS9UxzRgZtnrHExJxYL8K1hHpHzyGndVR 60NMcBxgs3LAMpnNT3dm43yHr+a9oCEE1b5aNoE7l1UW+NiuY3qhBrLj4NfzrvBgZCE4Xc+Tz7Yp9 pq6YeP7AcOgFOD6xuKnGYcc08avKgrX81ZpWG0WjfNNMGM1pzDKeFphy5PWU7W4PPD2+RUXOys6C0 eBnjc9TCNXjeQdUbOvdvhikOFo2B5BG23krCYgOHCmOqKbB+QLi/fUsBkzBaoR4VajPaZn8LdE4rD lMpIY2ID8AwSMwwAtT/w==; 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 1h1xW5-0007Mi-EC; Thu, 07 Mar 2019 18:13:13 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1xW2-0007M6-Hh for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2019 18:13:12 +0000 Received: by mail-pf1-x443.google.com with SMTP id n74so12041885pfi.9 for ; Thu, 07 Mar 2019 10:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FQjfEuWWPGlxVOFdaO+RnpbsWJ3NkSCVY4/xY49b5ak=; b=vbU/e/5/QeXMXOrI1YPxmI+V3wYWcqXTo6pO4TAcik2KDwjFJdHAOd/sofaqpBmIG5 KYe7EgszOiawv4ZIlhHH8W19VuJg6E5VLU1xgIHq5whfPEOUF7HTUaw59bjWGdrD698G PGqz/Zm4g3JvtoXDQh5usNJ4uKCucoeHFRTW7Ii5EbRks++7HkNnpP7EtRkPhlhYZSaa b2UcqBLourfr480pqmYxlt/EIao2nzZ2nrH4ObL/YK08kg4A0MAUfJWNccpkUootMhH5 Sdbc0mIXvgXbhRbD8gnrI4IAImGj7qFvmcVRixGOdwbfqGheKLDoDMyBKk11ihvYBtEM n/Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FQjfEuWWPGlxVOFdaO+RnpbsWJ3NkSCVY4/xY49b5ak=; b=HEHkS0wgpd+7VbAobo/Rib2DqzhsVBqHGZ51T9yFVFkxbNXOWyI/x14peZgg/yYPLB yyljil4gjkY2FqKnZWVSJBSvrZruFkdq/XFQo4ZirC1fLnncfZQl2WK+ynSBikrYJ/LN vDZWQDX7yYp7P1MCwVBhDpOEIVa1aWKZlJ08lynF/VTcn4j6KjHYyBVoX5AmVRkD+6oX z5wm4DjBYmNqAEra5yWFRem3r9xhQ3F5OM9Rjt8DgjZpGlmtE8fTC7kWcQG4Rfcbr4/M 5mw+WjwXdDX2dWbfGS44IZUXIpUailTR8+OAbK5a+jHM7zIIZ3/DAz3IVCHWGWcpIqnB gXUw== X-Gm-Message-State: APjAAAXZduvNcfLitFPbINmOlwinA4KQB8HHWPNrMlaEQjL3zE7N9V9u lTb3x33q+u6DAOyy0ydQCK/riityW2psaIppbPyvkQ== X-Google-Smtp-Source: APXvYqzQ9NSuypziQqqFe860leXDVL3Xmy19jNxDyNv0Vkvoluj93Ot6fP+Nvqm5P5bbtps/wne847HtxGa5aIn/hn8= X-Received: by 2002:a63:40c1:: with SMTP id n184mr12006577pga.225.1551982389545; Thu, 07 Mar 2019 10:13:09 -0800 (PST) MIME-Version: 1.0 References: <20190307162101.29204-1-natechancellor@gmail.com> <20190307180027.6226-1-natechancellor@gmail.com> In-Reply-To: <20190307180027.6226-1-natechancellor@gmail.com> From: Nick Desaulniers Date: Thu, 7 Mar 2019 10:12:58 -0800 Message-ID: Subject: Re: [PATCH v2] net: stmmac: Avoid sometimes uninitialized Clang warnings To: Nathan Chancellor X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190307_101310_588244_A6CBBD12 X-CRM114-Status: GOOD ( 24.96 ) 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: Alexandre Torgue , netdev@vger.kernel.org, LKML , linux-stm32@st-md-mailman.stormreply.com, clang-built-linux@googlegroups.com, Jose Abreu , Maxime Coquelin , Giuseppe Cavallaro , "David S. Miller" , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Mar 7, 2019 at 10:00 AM Nathan Chancellor wrote: > > 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 V2 LGTM, thanks for resending. > 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; > -- > 2.21.0 > > -- > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > To post to this group, send email to clang-built-linux@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20190307180027.6226-1-natechancellor%40gmail.com. > For more options, visit https://groups.google.com/d/optout. -- Thanks, ~Nick Desaulniers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel