]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
maint: fix "mixing declarations and code" errors
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Tue, 8 Nov 2022 19:12:22 +0000 (20:12 +0100)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Wed, 9 Nov 2022 17:22:47 +0000 (18:22 +0100)
clang 14.0.5 complains:

../src/bhyve/bhyve_device.c:42:29: error: mixing declarations and code
is incompatible with standards before C99
[-Werror,-Wdeclaration-after-statement]
    virDomainPCIAddressSet *addrs = opaque;
                            ^
1 error generated.

And a few similar errors in some other places, mainly bhyve related.
Apply a trivial fix to resolve that.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/bhyve/bhyve_device.c
tests/bhyvexml2argvmock.c
tests/domaincapstest.c
tests/networkxml2conftest.c

index 5654028ca5ab04622ef875daf49405c4cba5ec9d..e4d14c4102efd4c687539c2020444173858e4739 100644 (file)
@@ -36,11 +36,13 @@ bhyveCollectPCIAddress(virDomainDef *def G_GNUC_UNUSED,
                        virDomainDeviceInfo *info,
                        void *opaque)
 {
+    virDomainPCIAddressSet *addrs = NULL;
+    virPCIDeviceAddress *addr = NULL;
     if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE)
         return 0;
 
-    virDomainPCIAddressSet *addrs = opaque;
-    virPCIDeviceAddress *addr = &info->addr.pci;
+    addrs = opaque;
+    addr = &info->addr.pci;
 
     if (addr->domain == 0 && addr->bus == 0 && addr->slot == 0) {
             return 0;
index 9b77f97e5fefdd974d0c478b31278cbf158f2e4a..fe76564d5146bba825247fa8f8992d08edb0274d 100644 (file)
@@ -25,10 +25,10 @@ init_syms(void)
 DIR *
 opendir(const char *path)
 {
-    init_syms();
-
     g_autofree char *path_override = NULL;
 
+    init_syms();
+
     if (STREQ(path, "fakefirmwaredir")) {
         path_override = g_strdup(FAKEFIRMWAREDIR);
     } else if (STREQ(path, "fakefirmwareemptydir")) {
index b4cb1894c282d9ef91eee26a1b5d004a4c616726..b3cf4426f30f554b4eeea4b3800d054c065d60be 100644 (file)
@@ -397,8 +397,9 @@ mymain(void)
 #define DO_TEST_BHYVE(Name, Emulator, BhyveCaps, Type) \
     do { \
         g_autofree char *name = NULL; \
+        struct testData data; \
         name = g_strdup_printf("bhyve_%s.x86_64", Name); \
-        struct testData data = { \
+        data = (struct testData) { \
             .name = name, \
             .emulator = Emulator, \
             .arch = "x86_64", \
index 726f073ddc5f0f7b817fd6f5b2dc57eb32949148..d18985e060b1417f02c224b22de3275ee4a9ce65 100644 (file)
@@ -50,14 +50,16 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
 
     /* Any changes to this function ^^ should be reflected here too. */
 #ifndef __linux__
-    char * tmp;
+    {
+        char * tmp;
 
-    if (!(tmp = virStringReplace(confactual,
-                                 "except-interface=lo0\n",
-                                 "except-interface=lo\n")))
-        goto fail;
-    VIR_FREE(confactual);
-    confactual = g_steal_pointer(&tmp);
+        if (!(tmp = virStringReplace(confactual,
+                                     "except-interface=lo0\n",
+                                     "except-interface=lo\n")))
+            goto fail;
+        VIR_FREE(confactual);
+        confactual = g_steal_pointer(&tmp);
+    }
 #endif
 
     if (virTestCompareToFile(confactual, outconf) < 0)