From nobody Fri Apr 19 23:34:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487786130649562.8130570957944; Wed, 22 Feb 2017 09:55:30 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MHqEbQ007054; Wed, 22 Feb 2017 12:52:14 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MHqC0u029426 for ; Wed, 22 Feb 2017 12:52:12 -0500 Received: from dhcp-17-113.lcy.redhat.com ([10.42.17.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MHqBrF004838; Wed, 22 Feb 2017 12:52:12 -0500 From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Wed, 22 Feb 2017 17:52:02 +0000 Message-Id: <20170222175205.8073-2-berrange@redhat.com> In-Reply-To: <20170222175205.8073-1-berrange@redhat.com> References: <20170222175205.8073-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] Use explicit boolean comparison in OOM check 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" GCC 7 gets upset by if (!tmp && (size * count)) warning util/viralloc.c: In function 'virReallocN': util/viralloc.c:246:23: error: '*' in boolean context, suggest '&&' inste= ad [-Werror=3Dint-in-bool-context] if (!tmp && (size * count)) { ~~~~~~^~~~~~~~ Keep it happy by adding !=3D 0 to the right hand expression so it realizes we really are wanting to treat the result of the arithmetic expression as a boolean Signed-off-by: Daniel P. Berrange --- src/util/viralloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/viralloc.c b/src/util/viralloc.c index 812aa5b..81f99d9 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -243,7 +243,7 @@ int virReallocN(void *ptrptr, return -1; } tmp =3D realloc(*(void**)ptrptr, size * count); - if (!tmp && (size * count)) { + if (!tmp && ((size * count) !=3D 0)) { if (report) virReportOOMErrorFull(domcode, filename, funcname, linenr); return -1; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 23:34:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1487786170113594.2990172224567; Wed, 22 Feb 2017 09:56:10 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MHqxdQ019137; Wed, 22 Feb 2017 12:52:59 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MHqDWm029436 for ; Wed, 22 Feb 2017 12:52:13 -0500 Received: from dhcp-17-113.lcy.redhat.com ([10.42.17.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MHqBrG004838; Wed, 22 Feb 2017 12:52:13 -0500 From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Wed, 22 Feb 2017 17:52:03 +0000 Message-Id: <20170222175205.8073-3-berrange@redhat.com> In-Reply-To: <20170222175205.8073-1-berrange@redhat.com> References: <20170222175205.8073-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] libxl: fix empty string check for channel path 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The libxl code was checking that a 'char *' was !=3D '\0', instead of checking the first element in the string Signed-off-by: Daniel P. Berrange --- src/libxl/libxl_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 57ec661..ea28c93 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1121,7 +1121,7 @@ libxlDomainCreateChannelPTY(virDomainDefPtr def, libx= l_ctx *ctx) &channelinfo); =20 if (!ret && channelinfo.u.pty.path && - channelinfo.u.pty.path !=3D '\0') { + *channelinfo.u.pty.path !=3D '\0') { VIR_FREE(chr->source->data.file.path); ignore_value(VIR_STRDUP(chr->source->data.file.path, channelinfo.u.pty.path)); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 23:34:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487786174734381.39366400498; Wed, 22 Feb 2017 09:56:14 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MHr0I2000870; Wed, 22 Feb 2017 12:53:00 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MHqEMf029446 for ; Wed, 22 Feb 2017 12:52:14 -0500 Received: from dhcp-17-113.lcy.redhat.com ([10.42.17.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MHqBrH004838; Wed, 22 Feb 2017 12:52:13 -0500 From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Wed, 22 Feb 2017 17:52:04 +0000 Message-Id: <20170222175205.8073-4-berrange@redhat.com> In-Reply-To: <20170222175205.8073-1-berrange@redhat.com> References: <20170222175205.8073-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] qemu: add missing break in qemuDomainDeviceCalculatePCIConnectFlags 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" One of the conditions in qemuDomainDeviceCalculatePCIConnectFlags was missing a break that could result it in falling through to an incorrect codepath. Signed-off-by: Daniel P. Berrange --- src/qemu/qemu_domain_address.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 5b75044..27ca010 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -553,6 +553,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDevic= eDefPtr dev, return pciFlags; } } + break; =20 case VIR_DOMAIN_DEVICE_FS: /* the only type of filesystem so far is virtio-9p-pci */ --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 23:34:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487786132110432.94220090831357; Wed, 22 Feb 2017 09:55:32 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MHqH2A000821; Wed, 22 Feb 2017 12:52:17 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MHqFRv029459 for ; Wed, 22 Feb 2017 12:52:15 -0500 Received: from dhcp-17-113.lcy.redhat.com ([10.42.17.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MHqBrI004838; Wed, 22 Feb 2017 12:52:14 -0500 From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Wed, 22 Feb 2017 17:52:05 +0000 Message-Id: <20170222175205.8073-5-berrange@redhat.com> In-Reply-To: <20170222175205.8073-1-berrange@redhat.com> References: <20170222175205.8073-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] Add ATTRIBUTE_FALLTHROUGH for switch cases without break 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In GCC 7 there is a new warning triggered when a switch case has a conditional statement (eg if ... else...) and some of the code paths fallthrough to the next switch statement. e.g. conf/domain_conf.c: In function 'virDomainChrEquals': conf/domain_conf.c:14926:12: error: this statement may fall through [-Werro= r=3Dimplicit-fallthrough=3D] if (src->targetTypeAttr !=3D tgt->targetTypeAttr) ^ conf/domain_conf.c:14928:5: note: here case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: ^~~~ conf/domain_conf.c: In function 'virDomainChrDefFormat': conf/domain_conf.c:22143:12: error: this statement may fall through [-Werro= r=3Dimplicit-fallthrough=3D] if (def->targetTypeAttr) { ^ conf/domain_conf.c:22151:5: note: here default: ^~~~~~~ GCC introduced a __attribute__((fallthrough)) to let you indicate that this is intentionale behaviour rather than a bug. Signed-off-by: Daniel P. Berrange --- src/conf/domain_conf.c | 7 +++++++ src/conf/network_conf.c | 3 ++- src/internal.h | 8 ++++++++ src/lxc/lxc_container.c | 2 +- src/network/bridge_driver.c | 6 ++++++ tools/virsh-edit.c | 2 +- 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f718b9a..17995f7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14925,7 +14925,12 @@ virDomainChrEquals(virDomainChrDefPtr src, case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: if (src->targetTypeAttr !=3D tgt->targetTypeAttr) return false; + + ATTRIBUTE_FALLTHROUGH; + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + ATTRIBUTE_FALLTHROUGH; + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: return src->target.port =3D=3D tgt->target.port; break; @@ -22148,6 +22153,8 @@ virDomainChrDefFormat(virBufferPtr buf, def->target.port); break; } + ATTRIBUTE_FALLTHROUGH; + default: virBufferAsprintf(buf, "\n", def->target.port); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 0e20dac..48e0001 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -2442,7 +2442,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) def->name); goto error; } - /* fall through to next case */ + ATTRIBUTE_FALLTHROUGH; + case VIR_NETWORK_FORWARD_BRIDGE: if (def->delay || stp) { virReportError(VIR_ERR_XML_ERROR, diff --git a/src/internal.h b/src/internal.h index 334659d..74a43fa 100644 --- a/src/internal.h +++ b/src/internal.h @@ -218,6 +218,10 @@ # endif # endif =20 +# ifndef ATTRIBUTE_FALLTHROUGH +# define ATTRIBUTE_FALLTHROUGH __attribute__((fallthrough)) +# endif + # else # ifndef ATTRIBUTE_UNUSED # define ATTRIBUTE_UNUSED @@ -228,6 +232,10 @@ # ifndef ATTRIBUTE_RETURN_CHECK # define ATTRIBUTE_RETURN_CHECK # endif +# +# ifndef ATTRIBUTE_FALLTHROUGH +# define ATTRIBUTE_FALLTHROUGH do {} while(0) +# endif # endif /* __GNUC__ */ =20 =20 diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 601b9b0..99bd7e9 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -2042,7 +2042,7 @@ static int lxcContainerDropCapabilities(virDomainDefP= tr def, default: /* User specified capabilities to drop */ toDrop =3D (state =3D=3D VIR_TRISTATE_SWITCH_OFF); } - /* Fallthrough */ + ATTRIBUTE_FALLTHROUGH; =20 case VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW: if (policy =3D=3D VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 06759c6..c5ec282 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2715,6 +2715,8 @@ networkStartNetwork(virNetworkDriverStatePtr driver, * VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined * (since that is macvtap bridge mode). */ + ATTRIBUTE_FALLTHROUGH; + case VIR_NETWORK_FORWARD_PRIVATE: case VIR_NETWORK_FORWARD_VEPA: case VIR_NETWORK_FORWARD_PASSTHROUGH: @@ -2792,6 +2794,8 @@ networkShutdownNetwork(virNetworkDriverStatePtr drive= r, * VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined * (since that is macvtap bridge mode). */ + ATTRIBUTE_FALLTHROUGH; + case VIR_NETWORK_FORWARD_PRIVATE: case VIR_NETWORK_FORWARD_VEPA: case VIR_NETWORK_FORWARD_PASSTHROUGH: @@ -4974,6 +4978,8 @@ networkGetNetworkAddress(const char *netname, char **= netaddr) * fall through if netdef->bridge wasn't set, since that is * macvtap bridge mode network. */ + ATTRIBUTE_FALLTHROUGH; + case VIR_NETWORK_FORWARD_PRIVATE: case VIR_NETWORK_FORWARD_VEPA: case VIR_NETWORK_FORWARD_PASSTHROUGH: diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c index 16d6705..92a00b7 100644 --- a/tools/virsh-edit.c +++ b/tools/virsh-edit.c @@ -140,7 +140,7 @@ do { goto redefine; break; } - /* fall-through */ + ATTRIBUTE_FALLTHROUGH; #endif =20 default: --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list