mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
ldb:mod:sort: rearrange NULL checks
There are further changes coming here.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit d785c1991c
)
This commit is contained in:
parent
faed55f4f8
commit
5f52991b93
@ -121,15 +121,18 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo
|
|||||||
el1 = ldb_msg_find_element(*msg1, ac->attributeName);
|
el1 = ldb_msg_find_element(*msg1, ac->attributeName);
|
||||||
el2 = ldb_msg_find_element(*msg2, ac->attributeName);
|
el2 = ldb_msg_find_element(*msg2, ac->attributeName);
|
||||||
|
|
||||||
if (!el1 && el2) {
|
/*
|
||||||
|
* NULL elements sort at the end (regardless of ac->reverse flag).
|
||||||
|
*/
|
||||||
|
if (el1 == NULL && el2 == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (el1 == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (el1 && !el2) {
|
if (el2 == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!el1 && !el2) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ac->reverse)
|
if (ac->reverse)
|
||||||
return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]);
|
return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user