[PATCH 01/14] src: Tweak source code to allow C++ compilation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <rayhan.faizel@xxxxxxxxx>
---
 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 *this,
 
 
 bool
-virDomainAudioIsEqual(virDomainAudioDef *this,
-                      virDomainAudioDef *that)
-{
-    return this->type == that->type &&
-        this->id == that->id &&
-        this->timerPeriod == that->timerPeriod &&
-        virDomainAudioIOCommonIsEqual(&this->input, &that->input) &&
-        virDomainAudioIOCommonIsEqual(&this->output, &that->output) &&
-        virDomainAudioBackendIsEqual(this, that);
+virDomainAudioIsEqual(virDomainAudioDef *first,
+                      virDomainAudioDef *second)
+{
+    return first->type == second->type &&
+        first->id == second->id &&
+        first->timerPeriod == second->timerPeriod &&
+        virDomainAudioIOCommonIsEqual(&first->input, &second->input) &&
+        virDomainAudioIOCommonIsEqual(&first->output, &second->output) &&
+        virDomainAudioBackendIsEqual(first, second);
 }
 
 
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);
 
 const char *virDomainChrSourceDefGetPath(virDomainChrSourceDef *chr);
 
diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_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;
 
     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=%s, export=%s, bitmap=%s", deviceID, NULLSTR(export),
+    VIR_DEBUG("deviceID=%s, export=%s, bitmap=%s", deviceID, NULLSTR(nbd_export),
               NULLSTR(bitmap));
 
     QEMU_CHECK_MONITOR(mon);
 
-    return qemuMonitorJSONNBDServerAdd(mon, deviceID, export, writable,
+    return qemuMonitorJSONNBDServerAdd(mon, deviceID, nbd_export, writable,
                                        bitmap);
 }
 
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);
 
 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);
 
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;
 
 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;
 
 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,
 
 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_UNUSED_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,
 
 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 *receive)
 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_NONNULL(3)
+    G_GNUC_WARN_UNUSED_RESULT;
 
 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_UNUSED_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;
 
 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;
 
 int virNetDevMacVLanCreate(const char *ifname,
                            const virMacAddr *macaddress,
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.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;
 
     if (!orig || !mods)
         return 0;
diff --git a/src/util/virnetdevvportprofile.h b/src/util/virnetdevvportprofile.h
index 600b2093c5..1714116e9c 100644
--- a/src/util/virnetdevvportprofile.h
+++ b/src/util/virnetdevvportprofile.h
@@ -25,7 +25,7 @@
 
 #define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
 
-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);
 
 virNVMeDevice *
 virNVMeDeviceNew(const virPCIDeviceAddress *address,
-                 unsigned long namespace,
+                 unsigned long nvme_namespace,
                  bool managed)
 {
     virNVMeDevice *dev = NULL;
@@ -71,7 +71,7 @@ virNVMeDeviceNew(const virPCIDeviceAddress *address,
     dev = g_new0(virNVMeDevice, 1);
 
     virPCIDeviceAddressCopy(&dev->address, address);
-    dev->namespace = namespace;
+    dev->namespace = nvme_namespace;
     dev->managed = managed;
 
     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, virObjectUnref);
 
 virNVMeDevice *
 virNVMeDeviceNew(const virPCIDeviceAddress *address,
-                 unsigned long namespace,
+                 unsigned long nvme_namespace,
                  bool managed);
 
 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 @@
 
 
 int virSetHostUUIDStr(const char *host_uuid);
-int virGetHostUUID(unsigned char *host_uuid) ATTRIBUTE_NONNULL(1) G_NO_INLINE;
+int virGetHostUUID(unsigned char *host_uuid) G_NO_INLINE ATTRIBUTE_NONNULL(1);
 
 bool virUUIDIsValid(const unsigned char *uuid);
 
-- 
2.34.1



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux