On 2012年12月04日 18:38, Jiri Denemark wrote:
In order to be able to steal PCI device by its index in the list. --- src/libvirt_private.syms | 2 ++ src/util/pci.c | 60 +++++++++++++++++++++++++++++------------------- src/util/pci.h | 4 ++++ 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 41e2629..625490f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1000,10 +1000,12 @@ pciDeviceListAdd; pciDeviceListCount; pciDeviceListDel; pciDeviceListFind; +pciDeviceListFindIndex; pciDeviceListFree; pciDeviceListGet; pciDeviceListNew; pciDeviceListSteal; +pciDeviceListStealIndex; pciDeviceNetName; pciDeviceReAttachInit; pciDeviceSetManaged; diff --git a/src/util/pci.c b/src/util/pci.c index 191f99d..3ebf6f7 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -1554,35 +1554,36 @@ pciDeviceListCount(pciDeviceList *list) } pciDevice * -pciDeviceListSteal(pciDeviceList *list, - pciDevice *dev) +pciDeviceListStealIndex(pciDeviceList *list, + int idx) { - pciDevice *ret = NULL; - int i; - - for (i = 0; i< list->count; i++) { - if (list->devs[i]->domain != dev->domain || - list->devs[i]->bus != dev->bus || - list->devs[i]->slot != dev->slot || - list->devs[i]->function != dev->function) - continue; + pciDevice *ret; - ret = list->devs[i]; + if (idx< 0) + return NULL;
Per the function is not static, it's better to check the upper range of the list index too. Assuming all the new helpers are for later patches use, ACK with the index checking fixed. Osier -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list