From patchwork Fri Oct 28 15:18:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 79967 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1243659qge; Fri, 28 Oct 2016 08:45:45 -0700 (PDT) X-Received: by 10.13.240.70 with SMTP id z67mr12778749ywe.248.1477669545457; Fri, 28 Oct 2016 08:45:45 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e64si5464324ybi.316.2016.10.28.08.45.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 28 Oct 2016 08:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:49915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c09Lk-0001bw-4v for patch@linaro.org; Fri, 28 Oct 2016 11:45:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c092S-0001ou-L4 for qemu-devel@nongnu.org; Fri, 28 Oct 2016 11:25:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c092P-0007rI-HJ for qemu-devel@nongnu.org; Fri, 28 Oct 2016 11:25:48 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:56541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c092P-0007qw-9b; Fri, 28 Oct 2016 11:25:45 -0400 Received: from tsrv.tls.msk.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 5502243736; Fri, 28 Oct 2016 18:25:43 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.tls.msk.ru (Postfix) with SMTP id A99CFB67; Fri, 28 Oct 2016 18:18:58 +0300 (MSK) Received: (nullmailer pid 6079 invoked by uid 1000); Fri, 28 Oct 2016 15:18:56 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Fri, 28 Oct 2016 18:18:48 +0300 Message-Id: <35b6e94ba50cd92600a85eef444bc31df8999de1.1477667878.git.mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.62.121.231 Subject: [Qemu-devel] [PULL 17/23] s390: avoid always-true comparison in s390_pci_generate_fid() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Peter Maydell , Michael Tokarev Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Coverity points out that the comparison "fid <= ZPCI_MAX_FID" in s390_pci_generate_fid() is always true (because fid is 32 bits and ZPCI_MAX_FID is 0xffffffff). This isn't a bug because the real loop termination condition is expressed later via an "if (...) break;" inside the loop, but it is a bit odd. Rephrase the loop to avoid the unnecessary duplicate-but-never-true conditional. Signed-off-by: Peter Maydell Acked-by: Cornelia Huck Signed-off-by: Michael Tokarev --- hw/s390x/s390-pci-bus.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) -- 2.1.4 diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index b7f8bca..bbbe0b1 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -809,17 +809,11 @@ static uint32_t s390_pci_generate_fid(Error **errp) { uint32_t fid = 0; - while (fid <= ZPCI_MAX_FID) { + do { if (!s390_pci_find_dev_by_fid(fid)) { return fid; } - - if (fid == ZPCI_MAX_FID) { - break; - } - - fid++; - } + } while (fid++ != ZPCI_MAX_FID); error_setg(errp, "no free fid could be found"); return 0;