diff mbox series

tst_timer: fix qsort comparison function

Message ID 1563992624-4968-2-git-send-email-piotr.krzysztof.gawel@gmail.com
State Accepted
Headers show
Series tst_timer: fix qsort comparison function | expand

Commit Message

piotr.krzysztof.gawel July 24, 2019, 6:23 p.m. UTC
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(-)

Comments

Cyril Hrubis July 25, 2019, 2:39 p.m. UTC | #1
Hi!
Pushed, thanks.
diff mbox series

Patch

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);
 }
 
 /*