Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753961AbcCOVt2 (ORCPT ); Tue, 15 Mar 2016 17:49:28 -0400 Received: from e19.ny.us.ibm.com ([129.33.205.209]:57031 "EHLO e19.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752865AbcCOVt0 (ORCPT ); Tue, 15 Mar 2016 17:49:26 -0400 X-IBM-Helo: d01dlp01.pok.ibm.com X-IBM-MailFrom: jejb@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org;linux-scsi@vger.kernel.org Message-ID: <1458078554.2375.97.camel@linux.vnet.ibm.com> Subject: Re: [PATCH] qla2xxx: avoid maybe_uninitialized warning From: James Bottomley To: Arnd Bergmann , qla2xxx-upstream@qlogic.com, "Martin K. Petersen" Cc: Nicholas Bellinger , Himanshu Madhani , Quinn Tran , Alexei Potashnik , Bart Van Assche , Swapnil Nagle , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 15 Mar 2016 14:49:14 -0700 In-Reply-To: <1458078051-529344-1-git-send-email-arnd@arndb.de> References: <1458078051-529344-1-git-send-email-arnd@arndb.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16031521-0057-0000-0000-000003BDC485 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1518 Lines: 36 On Tue, 2016-03-15 at 22:40 +0100, Arnd Bergmann wrote: > The qlt_check_reserve_free_req() function produces an incorrect > warning when CONFIG_PROFILE_ANNOTATED_BRANCHES is set: > > drivers/scsi/qla2xxx/qla_target.c: In function > 'qlt_check_reserve_free_req': > drivers/scsi/qla2xxx/qla_target.c:1887:3: error: 'cnt_in' may be used > uninitialized in this function [-Werror=maybe-uninitialized] > ql_dbg(ql_dbg_io, vha, 0x305a, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > "qla_target(%d): There is no room in the request ring: vha > ->req->ring_index=%d, vha->req->cnt=%d, req_cnt=%d Req-out=%d Req > -in=%d Req-Length=%d\n", > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ~~~~~~~~~~ > vha->vp_idx, vha->req->ring_index, > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > vha->req->cnt, req_cnt, cnt, cnt_in, vha->req->length); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/scsi/qla2xxx/qla_target.c:1887:3: error: 'cnt' may be used > uninitialized in this function [-Werror=maybe-uninitialized] > > The problem is that gcc fails to track the state of the condition > across an annotated branch. > > This slightly rearranges the code to move the second if() block > into the first one, to avoid the warning while retaining the > behavior of the code. I thought our usual policy was to ask someone to fix the compiler when it emitted a spurious warning. James