From patchwork Fri Jun 9 12:43:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 773850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wkhmq4cpjz9s7v for ; Fri, 9 Jun 2017 22:43:55 +1000 (AEST) Received: from localhost ([::1]:54469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJJGb-0004cY-As for incoming@patchwork.ozlabs.org; Fri, 09 Jun 2017 08:43:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJJG7-0004YS-H1 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 08:43:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJJG6-0003cr-N9 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 08:43:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52778) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJJG3-0003Xy-WA; Fri, 09 Jun 2017 08:43:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC9B1811A7; Fri, 9 Jun 2017 12:43:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EC9B1811A7 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcody@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EC9B1811A7 Received: from localhost (ovpn-116-115.phx2.redhat.com [10.3.116.115]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 223E986321; Fri, 9 Jun 2017 12:43:17 +0000 (UTC) From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 9 Jun 2017 08:43:13 -0400 Message-Id: <20170609124313.8026-2-jcody@redhat.com> In-Reply-To: <20170609124313.8026-1-jcody@redhat.com> References: <20170609124313.8026-1-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 09 Jun 2017 12:43:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/1] block/gluster.c: Handle qdict_array_entries() failure 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: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In qemu_gluster_parse_json(), the call to qdict_array_entries() could return a negative error code, which we were ignoring because we assigned the result to an unsigned variable. Fix this by using the 'int' type instead, which matches the return type of qdict_array_entries() and also the type we use for the loop enumeration variable 'i'. (Spotted by Coverity, CID 1360960.) Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Message-id: 1496682098-1540-1-git-send-email-peter.maydell@linaro.org Signed-off-by: Jeff Cody --- block/gluster.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 031596a..addceed 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -493,8 +493,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, Error *local_err = NULL; char *str = NULL; const char *ptr; - size_t num_servers; - int i, type; + int i, type, num_servers; /* create opts info from runtime_json_opts list */ opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort);