aboutsummaryrefslogtreecommitdiff
path: root/qga/commands-win32.c
diff options
context:
space:
mode:
authorKfir Manor <kfir@daynix.com>2022-11-20 16:00:43 +0200
committerKonstantin Kostiuk <kkostiuk@redhat.com>2022-12-20 15:54:41 +0200
commit8e12ec8ee301632b0fabc97489ee5db8fe0d6851 (patch)
treeb638b4face58fbddef95e149bc4d5bafc74d3769 /qga/commands-win32.c
parent33698d3abf8ce65c38bb4b12b600b130d2682c79 (diff)
downloadqemu-8e12ec8ee301632b0fabc97489ee5db8fe0d6851.zip
qemu-8e12ec8ee301632b0fabc97489ee5db8fe0d6851.tar.gz
qemu-8e12ec8ee301632b0fabc97489ee5db8fe0d6851.tar.bz2
qga:/qga-win: adding a empty PCI address creation function
Refactoring code to avoid duplication of creating an empty PCI address code. Signed-off-by: Kfir Manor <kfir@daynix.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Diffstat (limited to 'qga/commands-win32.c')
-rw-r--r--qga/commands-win32.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 4df50ea..bd0f3cc 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -596,6 +596,18 @@ static void get_pci_address_for_device(GuestPCIAddress *pci,
}
}
+static GuestPCIAddress *get_empty_pci_address(void)
+{
+ GuestPCIAddress *pci = NULL;
+
+ pci = g_malloc0(sizeof(*pci));
+ pci->domain = -1;
+ pci->slot = -1;
+ pci->function = -1;
+ pci->bus = -1;
+ return pci;
+}
+
static GuestPCIAddress *get_pci_info(int number, Error **errp)
{
HDEVINFO dev_info = INVALID_HANDLE_VALUE;
@@ -605,13 +617,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
SP_DEVICE_INTERFACE_DATA dev_iface_data;
HANDLE dev_file;
int i;
- GuestPCIAddress *pci = NULL;
-
- pci = g_malloc0(sizeof(*pci));
- pci->domain = -1;
- pci->slot = -1;
- pci->function = -1;
- pci->bus = -1;
+ GuestPCIAddress *pci = get_empty_pci_address();
dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_DISK, 0, 0,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);