cvs-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cvs-cvs] Changes to ccvs/src/main.c


From: Mark D . Baushke
Subject: [Cvs-cvs] Changes to ccvs/src/main.c
Date: Thu, 29 Sep 2005 18:11:48 -0400

Index: ccvs/src/main.c
diff -u ccvs/src/main.c:1.261 ccvs/src/main.c:1.262
--- ccvs/src/main.c:1.261       Thu Sep 29 21:36:11 2005
+++ ccvs/src/main.c     Thu Sep 29 22:11:47 2005
@@ -786,7 +786,12 @@
 #ifdef O_NOCTTY
        flags |= O_NOCTTY;
 #endif
-       if (rightnow != (time_t)-1) {
+       if (rightnow != (time_t)-1)
+               while (rightnow > 0) {
+                   *--p = rightnow % (UCHAR_MAX + 1);
+                   rightnow /= UCHAR_MAX + 1;
+               }
+       else {
            /* try to use more random data */
            randbytes = COMMITID_RAW_SIZE;
            startrand = buf;
@@ -796,21 +801,10 @@
            len = read (fd, startrand, randbytes);
            close (fd);
        }
-       if (len > 0) {
-           /* time_t can be unsigned */
-           if (rightnow != (time_t)-1)
-               while (rightnow > 0) {
-                   *--p = rightnow % (UCHAR_MAX + 1);
-                   rightnow /= UCHAR_MAX + 1;
-               }
-       } else {
+       if (len <= 0) {
+           /* no random data was available so use pid */
            long int pid = (long int)getpid ();
-           p = (unsigned char *) (buf + sizeof (buf));
-           while (rightnow > 0) {
-               *--p = rightnow % (UCHAR_MAX + 1);
-               rightnow /= UCHAR_MAX + 1;
-           }
-           p = (unsigned char *) (buf + sizeof (buf) - sizeof (time_t));
+           p = (unsigned char *) (startrand + sizeof (pid));
            while (pid > 0) {
                *--p = pid % (UCHAR_MAX + 1);
                pid /= UCHAR_MAX + 1;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]