Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If ibv_get_device_list() returns null, there's obviously no device list to free, so we can just return - and, as ibv_free_device_list() is not guaranteed to do nothing when passed a null pointer and, in fact, will try to dereference the null pointer, we *must* return without calling ibv_free_device_list(). However, if it returns a list, but there are no devices in the list, we still have to free the list - the list is terminated with a null pointer, so it's not empty. The loop for adding devices from the list will terminate immediately if numdev is 0, so don't bother to check whether it's zero, just run the loop, which will do nothing if numdev is 0, and fall through to free the device list. While we're at it, replace a goto with a break that does the same thing.
- Loading branch information