[PATCH v2 03/11] qemu: QEMU_PCI constant consistency

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

 



Change QEMU_PCI_ADDRESS_LAST_SLOT to the number of slots in the bus,
not the maximum slot value, to match QEMU_PCI_ADDRESS_LAST_FUNCTION
and rename them both to have _LAST at the end.
---
 src/qemu/qemu_command.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ac5e1f3..119fd86 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1185,8 +1185,8 @@ cleanup:
     return ret;
 }
 
-#define QEMU_PCI_ADDRESS_LAST_SLOT 31
-#define QEMU_PCI_ADDRESS_LAST_FUNCTION 8
+#define QEMU_PCI_ADDRESS_SLOT_LAST 32
+#define QEMU_PCI_ADDRESS_FUNCTION_LAST 8
 struct _qemuDomainPCIAddressSet {
     virHashTablePtr used;
     virDevicePCIAddress lastaddr;
@@ -1263,7 +1263,7 @@ static int qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
         virDevicePCIAddress tmp_addr = info->addr.pci;
         unsigned int *func = &tmp_addr.function;
 
-        for (*func = 1; *func < QEMU_PCI_ADDRESS_LAST_FUNCTION; (*func)++) {
+        for (*func = 1; *func < QEMU_PCI_ADDRESS_FUNCTION_LAST; (*func)++) {
             addr = qemuPCIAddressAsString(&tmp_addr);
             if (!addr)
                 goto cleanup;
@@ -1385,7 +1385,7 @@ static int qemuDomainPCIAddressCheckSlot(qemuDomainPCIAddressSetPtr addrs,
     virDevicePCIAddress tmp_addr = *addr;
     unsigned int *func = &(tmp_addr.function);
 
-    for (*func = 0; *func < QEMU_PCI_ADDRESS_LAST_FUNCTION; (*func)++) {
+    for (*func = 0; *func < QEMU_PCI_ADDRESS_FUNCTION_LAST; (*func)++) {
         str = qemuPCIAddressAsString(&tmp_addr);
         if (!str)
             return -1;
@@ -1437,7 +1437,7 @@ int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
     unsigned int *func = &tmp_addr.function;
     unsigned int last;
 
-    for (*func = 0; *func < QEMU_PCI_ADDRESS_LAST_FUNCTION; (*func)++) {
+    for (*func = 0; *func < QEMU_PCI_ADDRESS_FUNCTION_LAST; (*func)++) {
         if (qemuDomainPCIAddressReserveAddr(addrs, &tmp_addr) < 0)
             goto cleanup;
     }
@@ -1498,7 +1498,7 @@ int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs,
     virDevicePCIAddress tmp_addr = *addr;
     unsigned int *func = &tmp_addr.function;
 
-    for (*func = 0; *func < QEMU_PCI_ADDRESS_LAST_FUNCTION; (*func)++) {
+    for (*func = 0; *func < QEMU_PCI_ADDRESS_FUNCTION_LAST; (*func)++) {
         str = qemuPCIAddressAsString(&tmp_addr);
         if (!str)
             return -1;
@@ -1536,8 +1536,8 @@ qemuDomainPCIAddressGetNextSlot(qemuDomainPCIAddressSetPtr addrs,
     char *addr;
 
     tmp_addr.slot++;
-    for (i = 0; i <= QEMU_PCI_ADDRESS_LAST_SLOT; i++, tmp_addr.slot++) {
-        if (QEMU_PCI_ADDRESS_LAST_SLOT < tmp_addr.slot) {
+    for (i = 0; i < QEMU_PCI_ADDRESS_SLOT_LAST; i++, tmp_addr.slot++) {
+        if (QEMU_PCI_ADDRESS_SLOT_LAST <= tmp_addr.slot) {
             tmp_addr.slot = 0;
         }
 
@@ -1692,7 +1692,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
      */
     memset(&tmp_addr, 0, sizeof(tmp_addr));
     tmp_addr.slot = 1;
-    for (*func = 0; *func < QEMU_PCI_ADDRESS_LAST_FUNCTION; (*func)++) {
+    for (*func = 0; *func < QEMU_PCI_ADDRESS_FUNCTION_LAST; (*func)++) {
         if ((*func == 1 && reservedIDE) ||
             (*func == 2 && reservedUSB))
             /* we have reserved this pci address */
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]