Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423533AbbEOCai (ORCPT ); Thu, 14 May 2015 22:30:38 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:44034 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423496AbbEOCaP (ORCPT ); Thu, 14 May 2015 22:30:15 -0400 Date: Thu, 14 May 2015 22:30:12 -0400 (EDT) Message-Id: <20150514.223012.1808412142637659689.davem@davemloft.net> To: bhelgaas@google.com Cc: ogerlitz@mellanox.com, jackm@dev.mellanox.co.il, matanb@mellanox.com, idos@mellanox.com, netdev@vger.kernel.org, yishaih@mellanox.com, amirv@mellanox.com, linux-kernel@vger.kernel.org, roland@purestorage.com Subject: Re: [PATCH] net/mlx4: Avoid 'may be used uninitialized' warnings From: David Miller In-Reply-To: <20150514231708.13594.13610.stgit@bhelgaas-glaptop2.roam.corp.google.com> References: <20150514231708.13594.13610.stgit@bhelgaas-glaptop2.roam.corp.google.com> X-Mailer: Mew version 6.6 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 14 May 2015 19:30:14 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1198 Lines: 35 From: Bjorn Helgaas Date: Thu, 14 May 2015 18:17:08 -0500 > With a cross-compiler based on gcc-4.9, I see warnings like the following: > > drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_CQ_wrapper': > drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:3048:10: error: 'cq' may be used uninitialized in this function [-Werror=maybe-uninitialized] > cq->mtt = mtt; > > I think the warning is spurious because we only use cq when > cq_res_start_move_to() returns zero, and it always initializes *cq in that > case. The srq case is similar. But maybe gcc isn't smart enough to figure > that out. > > Initialize cq and srq explicitly to avoid the warnings. > > Signed-off-by: Bjorn Helgaas Applied. The compiler, generally, is not good at determining use-before-initialized in situations of the form: int x; if (foo) x = whatever; ... if (foo) use(x); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/