usnic: explicitly handle case when both endpoints are NULL
If we don't explicitly declare that (a == NULL && b == NULL) is equivalent to qsort, we could end up with wonky sorting order. I.e., it's *possible* that some NULLs could end up in the middle of the array. Regardless of whether it will ever happen in practice, it makes the code more clear to also handle the "both are NULL" case. Also fix the 2-spacing indents. Reviewed by Dave Goodell. cmr=v1.8.2:reviewer=ompi-rm1.8 This commit was SVN r32259.
Этот коммит содержится в:
родитель
947a4e14b4
Коммит
b6075ea775
@ -80,10 +80,12 @@ static int map_compare_endpoints(const void *aa, const void *bb)
|
|||||||
ompi_btl_usnic_endpoint_t *a = *((ompi_btl_usnic_endpoint_t**) aa);
|
ompi_btl_usnic_endpoint_t *a = *((ompi_btl_usnic_endpoint_t**) aa);
|
||||||
ompi_btl_usnic_endpoint_t *b = *((ompi_btl_usnic_endpoint_t**) bb);
|
ompi_btl_usnic_endpoint_t *b = *((ompi_btl_usnic_endpoint_t**) bb);
|
||||||
|
|
||||||
if (NULL == a) {
|
if (NULL == a && NULL == b) {
|
||||||
return 1;
|
return 0;
|
||||||
|
} else if (NULL == a) {
|
||||||
|
return 1;
|
||||||
} else if (NULL == b) {
|
} else if (NULL == b) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return strcmp(ibv_get_device_name(a->endpoint_module->device),
|
return strcmp(ibv_get_device_name(a->endpoint_module->device),
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user