
On Mon, Jul 20, 2009 at 01:42:05PM -0400, Laine Stump wrote:
These functions are useful for an implementation of an interface driver that doesn't use a library that manages its own list of interfaces (as netcf does), for example the test interface driver.
+ +int virInterfaceFindByMACString(const virInterfaceObjListPtr interfaces, + const char *mac, + virInterfaceObjPtr *matches, int maxmatches) +{ + unsigned int i, matchct = 0; + + for (i = 0 ; i < interfaces->count ; i++) { + int lock_for_caller = 0; + virInterfaceObjLock(interfaces->objs[i]); + if (STREQ(interfaces->objs[i]->def->mac, mac)) { + if (matchct < maxmatches) { + matches[matchct] = interfaces->objs[i]; + lock_for_caller = 1; + } + matchct++; + } + if (!lock_for_caller) { + /* it is the caller's responsibility to unlock *all* matches */ + virInterfaceObjUnlock(interfaces->objs[i]); + } + }
I think it'd be a little nicer to just use 'continue' there instead of introducing the 'lock_for_caller = 1' assignment. Also minor indentation typo. ACK to this anyway Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|