[PATCH] qsort: use rand() not random()

Enrico Scholz <[email protected]> Sun, 26 Aug 2012 13:44:59 +0200
Newsgroups gmane.linux.lib.dietlibc
Message-ID <1345981499-30581-1-git-send-email-enrico.scholz@informatik.tu-chemnitz.de>
random(3) is marked deprecated and requires the _BSD_SOURCE feature.
Use rand(3) instead of which is an alias of random(3).  With old code,
build failed with:

| lib/qsort.c: In function 'quicksort':
| lib/qsort.c:33:3: error: implicit declaration of function 'random' [-Werror=implicit-function-declaration]
| cc1: some warnings being treated as errors

Signed-off-by: Enrico Scholz <[email protected]>
---
 lib/qsort.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/qsort.c b/lib/qsort.c
index 8c24b77..2523d5d 100644
--- a/lib/qsort.c
+++ b/lib/qsort.c
@@ -30,7 +30,7 @@ static void quicksort(char* base,size_t size,ssize_t l,ssize_t r,
      data is already sorted.  Try to improve by exchanging it with a
      random other pivot.
    */
-  exch(base,size,l+(random()%(r-l)),r);
+  exch(base,size,l+(rand()%(r-l)),r);
 #elif defined MID
   /*
      We chose the rightmost element in the array to be sorted as pivot,
-- 
1.7.11.4