From nobody Sat Nov 23 17:49:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1724084482836843.7957667754774; Mon, 19 Aug 2024 09:21:22 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B24BC166D; Mon, 19 Aug 2024 12:21:21 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6C6E1164C; Mon, 19 Aug 2024 12:20:00 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 100C0143E; Mon, 19 Aug 2024 12:19:55 -0400 (EDT) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F31CE13EF for ; Mon, 19 Aug 2024 12:19:53 -0400 (EDT) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2f15dd0b489so63447961fa.3 for ; Mon, 19 Aug 2024 09:19:53 -0700 (PDT) Received: from localhost.localdomain ([37.186.51.21]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bebbde4964sm5738298a12.24.2024.08.19.09.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 09:19:51 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724084392; x=1724689192; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lHzqFYqrrbdfvPJNKfJ1lv4ytVJNuWwI9U3JryU92Gs=; b=Dplr7SIGYOPP8eCTQhf5T0rT96+RqQCgB6xOjVvmV8d1R6kdeDBxY1l/19r8FYDzny xB5ebNHqVbYOnbeaA7D7uboLDY/7qUdWZYyGMx0EHDZFEJp1NkU/HSYA4zpKtmf0hjmP hj89PRPTFydr+tY78DOkmz+bgdRMmv2exW//Fs8h6LUq52tNkUwcK6LQSnrg0v7I+vCl 4z0iLdv87xNisnxYjn/lWJ2LjG56AjV+HzX81JZKRnuudx3RYj2gYPi3OY+0gBP3gwo9 FTytniOUrch8j//Q4+x6ayYDWqViMqH4a8O3nrlyKHZGMRKeq0aSIQCarEgpkm79MAFh FGBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724084392; x=1724689192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lHzqFYqrrbdfvPJNKfJ1lv4ytVJNuWwI9U3JryU92Gs=; b=hFvIjPzoFH/5/eezK8X7AhNzLY5EOYQK6FqxAZKIjalb6KGt0QwHGkwbUTEW/P/fog U2JoPySqvNx+nWqqQbsQysmprTm8CnyIFNu99+SE1gf2LUV+/pK9QqI4i9hqYop7+ukl wwEoQ2NH45El3NcaLMmwCxIWaFVRtYLdMDQWP+v/RE0c7OtnIJ6CUhe1yHSbT8SFjPRL J9LPBLZyC4LJbzfj7OELCbnM+4s1ZW92WwWQlS3mbY0sKGIeo1Un7VrZYsnd2lgNytAI 4ka+SY9S1U0YcHok6ZanYljMZYyKO/hH6nDnE1AWfu25euS8cXYuI8sD0uzzleAdW1fP RN6A== X-Gm-Message-State: AOJu0YxWHhSowsphw51znbClu059Lq6m+jAfDt56mDCyIg3l3LVYH2Ec a6LXH+bOlnTxtTOYfH2KOTlAAQPdtGcf0i63XTjg7HcOKQTUIIGC/OTD5g== X-Google-Smtp-Source: AGHT+IFNX4WjCUfW0VlrM8gmQvGdQdch7EcqNHV12fplPyRXcvSLHXtecvWH7vvpTENnfz0rrQfHxA== X-Received: by 2002:a2e:a596:0:b0:2f3:e2f0:af16 with SMTP id 38308e7fff4ca-2f3e2f0b27emr8564661fa.26.1724084391698; Mon, 19 Aug 2024 09:19:51 -0700 (PDT) From: Rayhan Faizel To: devel@lists.libvirt.org Subject: [PATCH 01/14] src: Tweak source code to allow C++ compilation Date: Mon, 19 Aug 2024 21:39:39 +0530 Message-Id: <20240819160952.351383-2-rayhan.faizel@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819160952.351383-1-rayhan.faizel@gmail.com> References: <20240819160952.351383-1-rayhan.faizel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KJG3KIK2AQANOVYDRYDMVWL6DDOCC6IL X-Message-ID-Hash: KJG3KIK2AQANOVYDRYDMVWL6DDOCC6IL X-MailFrom: rayhan.faizel@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Rayhan Faizel X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1724084483413116600 Content-Type: text/plain; charset="utf-8" Since the fuzzers require C++ and will include various libvirt headers, some minor fixups will be needed. 1. 'this' and 'namespace' are reserved C++ keywords so replace them. 2. There is an enum and struct sharing the same name virNetDevVPortProfile. This is not allowed under C++. 3. G_NO_INLINE works differently under C++. Some compile errors occur because of this. To work around this, we rearrange G_NO_INLINE to allow compilation while allowing libvirt to compile normally as before without fuzzing enabled. Signed-off-by: Rayhan Faizel --- src/conf/domain_conf.c | 18 +++++++++--------- src/conf/domain_conf.h | 4 ++-- src/conf/netdev_vport_profile_conf.c | 2 +- src/qemu/qemu_monitor.c | 6 +++--- src/qemu/qemu_monitor.h | 2 +- src/util/virfile.h | 2 +- src/util/virnetdev.h | 12 ++++++------ src/util/virnetdevip.h | 2 +- src/util/virnetdevmacvlan.h | 2 +- src/util/virnetdevvportprofile.c | 2 +- src/util/virnetdevvportprofile.h | 2 +- src/util/virnvme.c | 4 ++-- src/util/virnvme.h | 2 +- src/util/viruuid.h | 2 +- 14 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d950921667..61418c4bc2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29863,15 +29863,15 @@ virDomainAudioBackendIsEqual(virDomainAudioDef *t= his, =20 =20 bool -virDomainAudioIsEqual(virDomainAudioDef *this, - virDomainAudioDef *that) -{ - return this->type =3D=3D that->type && - this->id =3D=3D that->id && - this->timerPeriod =3D=3D that->timerPeriod && - virDomainAudioIOCommonIsEqual(&this->input, &that->input) && - virDomainAudioIOCommonIsEqual(&this->output, &that->output) && - virDomainAudioBackendIsEqual(this, that); +virDomainAudioIsEqual(virDomainAudioDef *first, + virDomainAudioDef *second) +{ + return first->type =3D=3D second->type && + first->id =3D=3D second->id && + first->timerPeriod =3D=3D second->timerPeriod && + virDomainAudioIOCommonIsEqual(&first->input, &second->input) && + virDomainAudioIOCommonIsEqual(&first->output, &second->output) && + virDomainAudioBackendIsEqual(first, second); } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index eae621f900..3e97dd6293 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4346,8 +4346,8 @@ virDomainSoundModelSupportsCodecs(virDomainSoundDef *= def); bool virDomainAudioIOCommonIsSet(virDomainAudioIOCommon *common); bool -virDomainAudioIsEqual(virDomainAudioDef *this, - virDomainAudioDef *that); +virDomainAudioIsEqual(virDomainAudioDef *first, + virDomainAudioDef *second); =20 const char *virDomainChrSourceDefGetPath(virDomainChrSourceDef *chr); =20 diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_p= rofile_conf.c index 032a3147d7..f815ac6bf5 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -181,7 +181,7 @@ void virNetDevVPortProfileFormat(const virNetDevVPortProfile *virtPort, virBuffer *buf) { - enum virNetDevVPortProfile type; + virNetDevVPortProfileType type; bool noParameters; =20 if (!virtPort) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7f65c23748..0a6acc5470 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3464,16 +3464,16 @@ qemuMonitorNBDServerStart(qemuMonitor *mon, int qemuMonitorNBDServerAdd(qemuMonitor *mon, const char *deviceID, - const char *export, + const char *nbd_export, bool writable, const char *bitmap) { - VIR_DEBUG("deviceID=3D%s, export=3D%s, bitmap=3D%s", deviceID, NULLSTR= (export), + VIR_DEBUG("deviceID=3D%s, export=3D%s, bitmap=3D%s", deviceID, NULLSTR= (nbd_export), NULLSTR(bitmap)); =20 QEMU_CHECK_MONITOR(mon); =20 - return qemuMonitorJSONNBDServerAdd(mon, deviceID, export, writable, + return qemuMonitorJSONNBDServerAdd(mon, deviceID, nbd_export, writable, bitmap); } =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 57d1b45bf5..0baf237f92 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1197,7 +1197,7 @@ int qemuMonitorNBDServerStart(qemuMonitor *mon, ATTRIBUTE_NONNULL(2); int qemuMonitorNBDServerAdd(qemuMonitor *mon, const char *deviceID, - const char *export, + const char *nbd_export, bool writable, const char *bitmap); int qemuMonitorNBDServerStop(qemuMonitor *mon); diff --git a/src/util/virfile.h b/src/util/virfile.h index 7df3fcb840..871aa06f14 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -215,7 +215,7 @@ void virFileActivateDirOverrideForLib(void); =20 off_t virFileLength(const char *path, int fd) ATTRIBUTE_NONNULL(1); bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1); -bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1) G_NO_INLINE; +bool virFileExists(const char *file) G_NO_INLINE ATTRIBUTE_NONNULL(1); bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1); bool virFileIsRegular(const char *file) ATTRIBUTE_NONNULL(1); =20 diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index c287a7b272..db22519a15 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -168,11 +168,11 @@ int virNetDevSetupControl(const char *ifname, G_GNUC_WARN_UNUSED_RESULT; =20 int virNetDevExists(const char *brname) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; + G_NO_INLINE ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; =20 int virNetDevSetOnline(const char *ifname, bool online) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; + G_NO_INLINE ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; int virNetDevGetOnline(const char *ifname, bool *online) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; @@ -180,7 +180,7 @@ int virNetDevGetOnline(const char *ifname, =20 int virNetDevSetMAC(const char *ifname, const virMacAddr *macaddr) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_= NO_INLINE; + G_NO_INLINE ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUS= ED_RESULT; int virNetDevGetMAC(const char *ifname, virMacAddr *macaddr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; @@ -202,7 +202,7 @@ int virNetDevSetCoalesce(const char *ifname, =20 int virNetDevSetMTU(const char *ifname, int mtu) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; + G_NO_INLINE ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; int virNetDevSetMTUFromDevice(const char *ifname, const char *otherifname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; @@ -323,8 +323,8 @@ int virNetDevGetRcvAllMulti(const char *ifname, bool *r= eceive) int virNetDevSysfsFile(char **pf_sysfs_device_link, const char *ifname, const char *file) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) - G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; + G_NO_INLINE ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNUL= L(3) + G_GNUC_WARN_UNUSED_RESULT; =20 int virNetDevRunEthernetScript(const char *ifname, const char *script) G_NO_INLINE; diff --git a/src/util/virnetdevip.h b/src/util/virnetdevip.h index fdf116f509..2b45d360ae 100644 --- a/src/util/virnetdevip.h +++ b/src/util/virnetdevip.h @@ -59,7 +59,7 @@ int virNetDevIPAddrAdd(const char *ifname, virSocketAddr *addr, virSocketAddr *peer, unsigned int prefix) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_= NO_INLINE; + G_NO_INLINE ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUS= ED_RESULT; int virNetDevIPRouteAdd(const char *ifname, virSocketAddr *addr, unsigned int prefix, diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h index a5c34d6417..5846018df1 100644 --- a/src/util/virnetdevmacvlan.h +++ b/src/util/virnetdevmacvlan.h @@ -47,7 +47,7 @@ typedef enum { } virNetDevMacVLanCreateFlags; =20 bool virNetDevMacVLanIsMacvtap(const char *ifname) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; + G_NO_INLINE ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; =20 int virNetDevMacVLanCreate(const char *ifname, const virMacAddr *macaddress, diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprof= ile.c index c755fa79ec..221e0888b3 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -279,7 +279,7 @@ static int virNetDevVPortProfileMerge(virNetDevVPortProfile *orig, const virNetDevVPortProfile *mods) { - enum virNetDevVPortProfile otype; + virNetDevVPortProfileType otype; =20 if (!orig || !mods) return 0; diff --git a/src/util/virnetdevvportprofile.h b/src/util/virnetdevvportprof= ile.h index 600b2093c5..1714116e9c 100644 --- a/src/util/virnetdevvportprofile.h +++ b/src/util/virnetdevvportprofile.h @@ -25,7 +25,7 @@ =20 #define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40 =20 -typedef enum virNetDevVPortProfile { +typedef enum _virNetDevVPortProfileType { VIR_NETDEV_VPORT_PROFILE_NONE, VIR_NETDEV_VPORT_PROFILE_8021QBG, VIR_NETDEV_VPORT_PROFILE_8021QBH, diff --git a/src/util/virnvme.c b/src/util/virnvme.c index 37333d515b..e996ae2c5b 100644 --- a/src/util/virnvme.c +++ b/src/util/virnvme.c @@ -63,7 +63,7 @@ VIR_ONCE_GLOBAL_INIT(virNVMe); =20 virNVMeDevice * virNVMeDeviceNew(const virPCIDeviceAddress *address, - unsigned long namespace, + unsigned long nvme_namespace, bool managed) { virNVMeDevice *dev =3D NULL; @@ -71,7 +71,7 @@ virNVMeDeviceNew(const virPCIDeviceAddress *address, dev =3D g_new0(virNVMeDevice, 1); =20 virPCIDeviceAddressCopy(&dev->address, address); - dev->namespace =3D namespace; + dev->namespace =3D nvme_namespace; dev->managed =3D managed; =20 return dev; diff --git a/src/util/virnvme.h b/src/util/virnvme.h index ceef402c4b..f1d0bb5da0 100644 --- a/src/util/virnvme.h +++ b/src/util/virnvme.h @@ -33,7 +33,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNVMeDeviceList, virObjec= tUnref); =20 virNVMeDevice * virNVMeDeviceNew(const virPCIDeviceAddress *address, - unsigned long namespace, + unsigned long nvme_namespace, bool managed); =20 void diff --git a/src/util/viruuid.h b/src/util/viruuid.h index 9667bd3200..9d0b6d1b00 100644 --- a/src/util/viruuid.h +++ b/src/util/viruuid.h @@ -41,7 +41,7 @@ =20 =20 int virSetHostUUIDStr(const char *host_uuid); -int virGetHostUUID(unsigned char *host_uuid) ATTRIBUTE_NONNULL(1) G_NO_INL= INE; +int virGetHostUUID(unsigned char *host_uuid) G_NO_INLINE ATTRIBUTE_NONNULL= (1); =20 bool virUUIDIsValid(const unsigned char *uuid); =20 --=20 2.34.1