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(a)gmail.com>
---
src/bhyve/bhyve_device.c | 6 ++++--
tests/bhyvexml2argvmock.c | 4 ++--
tests/domaincapstest.c | 3 ++-
tests/networkxml2conftest.c | 16 +++++++++-------
4 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index 5654028ca5..e4d14c4102 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -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;
diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c
index 9b77f97e5f..fe76564d51 100644
--- a/tests/bhyvexml2argvmock.c
+++ b/tests/bhyvexml2argvmock.c
@@ -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")) {
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index b4cb1894c2..b3cf4426f3 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -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", \
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index 726f073ddc..d18985e060 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -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)
--
2.38.0