]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Use srand()/rand() instead of srandom()/random(); seems to be more portable
authorAlexander Barton <alex@barton.de>
Sun, 26 Jun 2011 21:39:20 +0000 (23:39 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 26 Jun 2011 21:39:20 +0000 (23:39 +0200)
src/ngircd/irc-login.c
src/ngircd/ngircd.c
src/ngircd/proc.c

index 2e99d66eeade7dfa36c25b6dd36f88a9c94f1c1e..067703a81f64db01bb1a5f30d8b60a73d3f48127 100644 (file)
@@ -273,7 +273,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
 
 #ifndef STRICT_RFC
                        if (Conf_AuthPing) {
-                               Conn_SetAuthPing(Client_Conn(Client), random());
+                               Conn_SetAuthPing(Client_Conn(Client), rand());
                                IRC_WriteStrClient(Client, "PING :%ld",
                                        Conn_GetAuthPing(Client_Conn(Client)));
                                LogDebug("Connection %d: sent AUTH PING %ld ...",
index 58383cfaac51924b6782be3d7a08bf7a96a1056e..500d1288efccf80ef8eeb3bc0a64a91e6fb2b974 100644 (file)
@@ -576,13 +576,13 @@ Random_Init_Kern(const char *file)
                if (read(fd, &seed, sizeof(seed)) == sizeof(seed))
                        ret = true;
                close(fd);
-               srandom(seed);
+               srand(seed);
        }
        return ret;
 }
 
 /**
- * Initialize libc random(3) number generator
+ * Initialize libc rand(3) number generator
  */
 static void
 Random_Init(void)
@@ -593,7 +593,7 @@ Random_Init(void)
                return;
        if (Random_Init_Kern("/dev/arandom"))
                return;
-       srandom(random() ^ getpid() ^ time(NULL));
+       srand(rand() ^ getpid() ^ time(NULL));
 }
 
 
index 217eb6d3ba17a3d22613caabfb2662e6c9f4cccc..54b3919c3374873664d52095cf990eb6f2619bbc 100644 (file)
@@ -62,7 +62,7 @@ Proc_Fork(PROC_STAT *proc, int *pipefds, void (*cbfunc)(int, short), int timeout
                return -1;
        }
 
-       seed = (unsigned int)random();
+       seed = (unsigned int)rand();
        pid = fork();
        switch (pid) {
        case -1:
@@ -73,7 +73,7 @@ Proc_Fork(PROC_STAT *proc, int *pipefds, void (*cbfunc)(int, short), int timeout
                return -1;
        case 0:
                /* New child process: */
-               srandom(seed ^ (unsigned int)time(NULL) ^ getpid());
+               srand(seed ^ (unsigned int)time(NULL) ^ getpid());
                Signals_Exit();
                signal(SIGTERM, Proc_GenericSignalHandler);
                signal(SIGALRM, Proc_GenericSignalHandler);