Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932730AbcCOVlL (ORCPT ); Tue, 15 Mar 2016 17:41:11 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:54557 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932427AbcCOVlI (ORCPT ); Tue, 15 Mar 2016 17:41:08 -0400 From: Arnd Bergmann To: qla2xxx-upstream@qlogic.com, "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Nicholas Bellinger , Himanshu Madhani , Quinn Tran , Alexei Potashnik , Bart Van Assche , Swapnil Nagle , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] qla2xxx: avoid maybe_uninitialized warning Date: Tue, 15 Mar 2016 22:40:31 +0100 Message-Id: <1458078051-529344-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:qnss9+WR1GnaT7ZQoBEOgrGlzwPYx97rfmJ6ygXESBNn7+3+3Yn 9Igf+c5FgVk51nHYUWvv6cihdVDkafvs3fmIqvhOsjR8D/mi6MxIjPUTicTvu8K8S/7QgHB c0DV/cGlmJJTwVxhPWP06B8yk+dzB0aKmsnyaTKJ1L+IEhdnVOqlXKQWL/OE5mQrS+/JQCu Y7uvNDUdIwIKDKNeN9VKw== X-UI-Out-Filterresults: notjunk:1;V01:K0:kBmQMke0Lkk=:yBCj59psrX3flqLx681FOR BORwnorTby4SveVo9ZnivPv12pctDocwp9/IHWewCfeisthywT6hWsz+9kn9rOj16afnf/oaj TqEhIKj9GH3831N5Iv36o/z/PKxCSp1Vyh0M7L3gj+R7CA+J44dj82ylgNB7WsLcl5/rAjIUi gex6WJCZCyfDzWDZrjacjItCStQmTnRindso/poO4UM37J16Xcq+Qs/y1zym4u46YljXecpba /+2G5VlnZBtS9rViI6nqNbFKvfiiUfcqQW4YUG7sGqae4FOs00NkRhM72jrQtNLhe4rHUKbaq nK31F/EMSBEemTnQNZnsfQRGuoStVs6stTTwCEu+TztDaTxSAyui9rcHpyUrFtwQZL/6Te2iO VkDX+vf6OIU7Lm/sfHSEBi9w2dEmjGLAj8Lf34fsDW3xAtBj9cvu0U0sXf1a7r0u8NqJJ+Z5X Dnt8CGoTcGw4WcTuL2YvRQCzFmE9ssNn7Md6uEXPQW+jarHdzXMDhslNbFl4U50NYPru1K0PB UVfxWL77hssAQ9bVquXDOWdDYmaqmBWBS33qNeRvvcDkiTBbDpvLYf3ygK2ESFkGduEXMwR7I 2xswaD6N3Lic42SI5drRPS199p+vqW9TXYUlcF9URG6vMcU+9MwYmpn0osDGqKm7JsXRyYs/W DQMk9KFGLbI4+wRoEdi6QGZj7B8b8Mug5hTO2+G3CrjFf3sKJdz1X2/8IOzhj1svmxv4= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2627 Lines: 58 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. Signed-off-by: Arnd Bergmann --- drivers/scsi/qla2xxx/qla_target.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 985231900aca..8a44d1541eb4 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -1881,15 +1881,17 @@ static int qlt_check_reserve_free_req(struct scsi_qla_host *vha, else vha->req->cnt = vha->req->length - (vha->req->ring_index - cnt); - } - if (unlikely(vha->req->cnt < (req_cnt + 2))) { - 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); - return -EAGAIN; + if (unlikely(vha->req->cnt < (req_cnt + 2))) { + 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); + return -EAGAIN; + } } + vha->req->cnt -= req_cnt; return 0; -- 2.7.0