[LTP] [PATCH] tst_timer: fix qsort comparison function
Piotr Gawel
piotr.krzysztof.gawel@gmail.com
Wed Jul 24 20:23:43 CEST 2019
>From qsort() manual:
The comparison function must return an integer
less than, equal to, or greater than zero if the
first argument is considered to be respectively
less than, equal to, or greater than the second.
If two members compare as equal, their order in
the sorted array is undefined.
We need it in descending order so the logic is
reverted.
Signed-off-by: Piotr Gawel <piotr.krzysztof.gawel@gmail.com>
---
lib/tst_timer_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index 4c16b59..f6459e5 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -159,7 +159,7 @@ static int cmp(const void *a, const void *b)
{
const long long *aa = a, *bb = b;
- return *aa < *bb;
+ return (*bb - *aa);
}
/*
--
2.7.4
More information about the ltp
mailing list