mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +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>
This commit is contained in:
parent
20ce68f159
commit
d785c1991c
@ -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);
|
||||
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;
|
||||
}
|
||||
if (el1 && !el2) {
|
||||
if (el2 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (!el1 && !el2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ac->reverse)
|
||||
return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user