maint: fix "mixing declarations and code" errors

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>
This commit is contained in:
Roman Bogorodskiy 2022-11-08 20:12:22 +01:00
parent 9dbdf9ced8
commit 2e16c9f202
4 changed files with 17 additions and 12 deletions

View File

@ -36,11 +36,13 @@ bhyveCollectPCIAddress(virDomainDef *def G_GNUC_UNUSED,
virDomainDeviceInfo *info, virDomainDeviceInfo *info,
void *opaque) void *opaque)
{ {
virDomainPCIAddressSet *addrs = NULL;
virPCIDeviceAddress *addr = NULL;
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE)
return 0; return 0;
virDomainPCIAddressSet *addrs = opaque; addrs = opaque;
virPCIDeviceAddress *addr = &info->addr.pci; addr = &info->addr.pci;
if (addr->domain == 0 && addr->bus == 0 && addr->slot == 0) { if (addr->domain == 0 && addr->bus == 0 && addr->slot == 0) {
return 0; return 0;

View File

@ -25,10 +25,10 @@ init_syms(void)
DIR * DIR *
opendir(const char *path) opendir(const char *path)
{ {
init_syms();
g_autofree char *path_override = NULL; g_autofree char *path_override = NULL;
init_syms();
if (STREQ(path, "fakefirmwaredir")) { if (STREQ(path, "fakefirmwaredir")) {
path_override = g_strdup(FAKEFIRMWAREDIR); path_override = g_strdup(FAKEFIRMWAREDIR);
} else if (STREQ(path, "fakefirmwareemptydir")) { } else if (STREQ(path, "fakefirmwareemptydir")) {

View File

@ -397,8 +397,9 @@ mymain(void)
#define DO_TEST_BHYVE(Name, Emulator, BhyveCaps, Type) \ #define DO_TEST_BHYVE(Name, Emulator, BhyveCaps, Type) \
do { \ do { \
g_autofree char *name = NULL; \ g_autofree char *name = NULL; \
struct testData data; \
name = g_strdup_printf("bhyve_%s.x86_64", Name); \ name = g_strdup_printf("bhyve_%s.x86_64", Name); \
struct testData data = { \ data = (struct testData) { \
.name = name, \ .name = name, \
.emulator = Emulator, \ .emulator = Emulator, \
.arch = "x86_64", \ .arch = "x86_64", \

View File

@ -50,6 +50,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
/* Any changes to this function ^^ should be reflected here too. */ /* Any changes to this function ^^ should be reflected here too. */
#ifndef __linux__ #ifndef __linux__
{
char * tmp; char * tmp;
if (!(tmp = virStringReplace(confactual, if (!(tmp = virStringReplace(confactual,
@ -58,6 +59,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
goto fail; goto fail;
VIR_FREE(confactual); VIR_FREE(confactual);
confactual = g_steal_pointer(&tmp); confactual = g_steal_pointer(&tmp);
}
#endif #endif
if (virTestCompareToFile(confactual, outconf) < 0) if (virTestCompareToFile(confactual, outconf) < 0)