From nobody Sat May 4 23:27:07 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532616660214171.03388960039285; Thu, 26 Jul 2018 07:51:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8FD8C0587EE; Thu, 26 Jul 2018 14:50:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71DAB6312F; Thu, 26 Jul 2018 14:50:57 +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 099DE4EE0D; Thu, 26 Jul 2018 14:50:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QEotFF001375 for ; Thu, 26 Jul 2018 10:50:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4C8B6215670C; Thu, 26 Jul 2018 14:50:55 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 849BD2156701; Thu, 26 Jul 2018 14:50:54 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 26 Jul 2018 15:50:51 +0100 Message-Id: <20180726145051.25341-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] conf: don't use virDomainVirtType in struct field 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-Type: text/plain; charset="utf-8" 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 26 Jul 2018 14:50:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Use of enum types for struct fields is generally avoided since it causes warnings if the compiler assumes the enum is unsigned. For example commit 8e2982b5767a25e5da6533c65bfdc648c95b3c69 Author: Cole Robinson Date: Tue Jul 24 16:27:54 2018 -0400 conf: Clean up virDomainDefParseCaps Introduced a line: if ((def->virtType =3D virDomainVirtTypeFromString(virttype)) < 0) { which causes a build failure with CLang conf/domain_conf.c:19143:65: error: comparison of unsigned enum expressio= n < 0 is always false [-Werror,-Wtautological-compare] as the compiler is free to optimize away the "< 0" check due to the assumption that the enum type is unsigned and always in range. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_process.c | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) Pushing as a build fix for CLang diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c27c874d9e..f94a90fbcc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15075,7 +15075,7 @@ virDomainVideoDefaultRAM(const virDomainDef *def, int virDomainVideoDefaultType(const virDomainDef *def) { - switch (def->virtType) { + switch ((virDomainVirtType)def->virtType) { case VIR_DOMAIN_VIRT_TEST: case VIR_DOMAIN_VIRT_XEN: if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_XEN || diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a804e86f6c..c1dfa37fdf 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2386,7 +2386,7 @@ struct _virDomainVirtioOptions { typedef struct _virDomainDef virDomainDef; typedef virDomainDef *virDomainDefPtr; struct _virDomainDef { - virDomainVirtType virtType; + int virtType; /* enum virDomainVirtType */ int id; unsigned char uuid[VIR_UUID_BUFLEN]; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ae45c45b7f..d148db90fa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7163,7 +7163,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, virCommandAddArg(cmd, "-machine"); virBufferAdd(&buf, def->os.machine, -1); =20 - switch (def->virtType) { + switch ((virDomainVirtType)def->virtType) { case VIR_DOMAIN_VIRT_QEMU: virBufferAddLit(&buf, ",accel=3Dtcg"); break; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 27bd8b9465..c4e33723d1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7191,6 +7191,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UN= USED, virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); virCapsPtr caps =3D NULL; bool active =3D false; + virDomainVirtType virtType; =20 VIR_DEBUG("Beginning VM attach process"); =20 @@ -7342,8 +7343,9 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UN= USED, goto exit_monitor; if (qemuMonitorGetStatus(priv->mon, &running, &reason) < 0) goto exit_monitor; - if (qemuMonitorGetVirtType(priv->mon, &vm->def->virtType) < 0) + if (qemuMonitorGetVirtType(priv->mon, &virtType) < 0) goto exit_monitor; + vm->def->virtType =3D virtType; if (qemuDomainObjExitMonitor(driver, vm) < 0) goto error; =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list