From nobody Fri Mar 29 07:36:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565788414; cv=none; d=zoho.com; s=zohoarc; b=gi3uylf3N9AJMGmNLpEoGCJPZXaNp8+kE36LnzrO1EpiV3nABrHg+XBGxpbKQA6aMn2kPd6Lfyr5dnRfg7S/Me883fhLdYEAV8CzXXrEEttXe2SI0HhcKvEIE00L8t9ywigHIH39gAwO0lJ9j9ucHZDDW1w3upRsZGz8sQ2MX0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565788414; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=fJCbccjuvDRskmuidK8VAMSfqzWS04a1jSNDH13dgYA=; b=GqAdwsYmNGpgLO59CR66W1VBOu7yyLVHt/rBAXDPqNIuNxooV79r6GgEu/j7G7kblFY9Il4VufhnVkcVqEYzMf2OyhKCGfIIFVBsTtu4oay/SKqwpejizrQsdqrXZfWHcBHfa1RvZWdqRmXw3By7zRawifw9EIjSyUU1CQotZqk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156578841401758.51286172971413; Wed, 14 Aug 2019 06:13:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7401309265B; Wed, 14 Aug 2019 13:13:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F7B481766; Wed, 14 Aug 2019 13:13:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F2F0D1806B00; Wed, 14 Aug 2019 13:13:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7EDDPbM019688 for ; Wed, 14 Aug 2019 09:13:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A3D91048133; Wed, 14 Aug 2019 13:13:25 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9A591001B2B; Wed, 14 Aug 2019 13:13:22 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 15:13:18 +0200 Message-Id: <20190814131318.117948-1-mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] remote_daemon_dispatch.c: typecast ARRAY_CARDINALITY() in remoteDispatchProbeURI() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 14 Aug 2019 13:13:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Since users can enable/disable drivers at compile time, it may happen that @drivers array is in fact empty (in both its occurrences within the function). This means that ARRAY_CARDINALITY() returns 0UL which makes gcc unhappy because of loop condition: i < ARRAY_CARDINALITY(drivers) GCC complains that @i is unsigned and comparing an unsigned value against 0 is always false. However, changing the type of @i to ssize_t is not enough, because compiler still sees the unsigned zero. The solution is to typecast the ARRAY_CARDINALITY(). Signed-off-by: Michal Privoznik Reviewed-by: Jim Fehlig --- src/remote/remote_daemon_dispatch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index c8e353ebd3..1bd281dd6d 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -2141,9 +2141,9 @@ remoteDispatchProbeURI(bool readonly, "vbox", # endif }; - size_t i; + ssize_t i; =20 - for (i =3D 0; i < ARRAY_CARDINALITY(drivers) && !*probeduri; i++) { + for (i =3D 0; i < (ssize_t) ARRAY_CARDINALITY(drivers) && !*probed= uri; i++) { VIR_AUTOFREE(char *) daemonname =3D NULL; VIR_AUTOFREE(char *) daemonpath =3D NULL; =20 @@ -2187,9 +2187,9 @@ remoteDispatchProbeURI(bool readonly, "vz", # endif }; - size_t i; + ssize_t i; =20 - for (i =3D 0; i < ARRAY_CARDINALITY(drivers) && !*probeduri; i++) { + for (i =3D 0; i < (ssize_t) ARRAY_CARDINALITY(drivers) && !*probed= uri; i++) { VIR_AUTOFREE(char *) sockname =3D NULL; =20 if (virAsprintf(&sockname, "%s/run/libvirt/virt%sd-%s", --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list