]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Tidy up gettimeofday usage
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 3 Apr 2011 15:09:44 +0000 (16:09 +0100)
committerDerrick Brashear <shadow@dementia.org>
Tue, 5 Apr 2011 18:17:53 +0000 (11:17 -0700)
The roken gettimeofday implementation doesn't return timezone
information. Audit the whole code to make sure that we don't rely on
this, and tidy up those places where we were passing an unused
timezone structure to the gettimeofday call.

Change-Id: Ia83f86483a9c7262fc0904236c0d039a912e3731
Reviewed-on: http://gerrit.openafs.org/4430
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
16 files changed:
src/JAVA/libjafs/File.c
src/butc/lwps.c
src/butc/tcudbprocs.c
src/butm/test_ftm.c
src/comerr/error_table_nt.c
src/kauth/kaprocs.c
src/lwp/test/selsubs.c
src/rx/rx.c
src/rx/test/kctest.c
src/rxkad/bg-fcrypt.c
src/rxkad/fc_test.c
src/rxkad/test/stress_c.c
src/tests/afscp.c
src/venus/afsio.c
src/vol/vol-salvage.c
src/volser/voltrans.c

index 734b6db4ef01c382f71524fd0f59c86d4f99c032..0804742199c1ec1310bb5542c72681214e6b89da 100644 (file)
@@ -132,7 +132,6 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_setAttributes
     jboolean islink = JNI_FALSE;
     int i;
     struct timeval tv0, tv1;
-    struct timezone tz;
 
     /*memset(target, 0, FILENAME_MAX);*/
 
@@ -152,12 +151,12 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_setAttributes
       return JNI_FALSE;
     }
 
-    gettimeofday(&tv0, &tz);
+    gettimeofday(&tv0, NULL);
     if ((strcmp(dirName, "/afs") == 0) || (strcmp(dirName, "/afs/") == 0)) {
       rc = 1;   /* special case for /afs since statmountpoint fails on it */
     } else {
       rc = uafs_statmountpoint(dirName);
-      gettimeofday(&tv1, &tz);
+      gettimeofday(&tv1, NULL);
       sub_time(&tv1, &tv0);
       /*printf("%s: statmountpoint %d.%06d\n", dirName, tv1.tv_sec, tv1.tv_usec);*/
     }
index cce1bc7b8dfd84efcba9061e8b0da230f19a68e9..1bceba71e137409f102c6668b4537e8be291204e 100644 (file)
@@ -116,7 +116,6 @@ extern struct tapeConfig globalTapeConfig;
 extern struct deviceSyncNode *deviceLatch;
 extern char globalCellName[];
 struct timeval tp;
-struct timezone tzp;
 
 /* forward declaration */
 afs_int32 readVolumeHeader(char *, afs_int32, struct volumeHeader *);
@@ -1811,7 +1810,6 @@ GetNewLabel(struct butm_tapeInfo *tapeInfoPtr, char *pName, char *AFSName,
            struct butm_tapeLabel *tapeLabel)
 {
     struct timeval tp;
-    struct timezone tzp;
     afs_uint32 size;
 
     memset(tapeLabel, 0, sizeof(struct butm_tapeLabel));
@@ -1823,7 +1821,7 @@ GetNewLabel(struct butm_tapeInfo *tapeInfoPtr, char *pName, char *AFSName,
     } else {
        size = 0;               /* no tape size */
     }
-    gettimeofday(&tp, &tzp);
+    gettimeofday(&tp, NULL);
 
     tapeLabel->structVersion = CUR_TAPE_VERSION;
     tapeLabel->creationTime = tp.tv_sec;
@@ -1971,13 +1969,12 @@ tapeExpired(struct butm_tapeLabel *tapeLabelPtr)
 {
     Date expiration;
     struct timeval tp;
-    struct timezone tzp;
 
     expiration = ExpirationDate(tapeLabelPtr->dumpid);
     if (!expiration)
        expiration = tapeLabelPtr->expirationDate;
 
-    gettimeofday(&tp, &tzp);
+    gettimeofday(&tp, NULL);
     return ((expiration < tp.tv_sec) ? 1 : 0);
 }
 
index 6d70941042e00c43828d29cdf0b976bc0b3af951..450f4d53be514d0dadee346d182ef28cc89eec0e 100644 (file)
@@ -125,7 +125,6 @@ GetDBTape(afs_int32 taskId, Date expires, struct butm_tapeInfo *tapeInfoPtr,
     char tapeName[BU_MAXTAPELEN];
     char strlevel[5];
     struct timeval tp;
-    struct timezone tzp;
     afs_int32 curTime;
     int tapecount = 1;
 
@@ -239,7 +238,7 @@ GetDBTape(afs_int32 taskId, Date expires, struct butm_tapeInfo *tapeInfoPtr,
             */
            else {
                /* Check the tape's expiration date. Use the expiration on the label */
-               gettimeofday(&tp, &tzp);
+               gettimeofday(&tp, NULL);
                curTime = tp.tv_sec;
                if (curTime < oldTapeLabel.expirationDate) {
                    TLog(taskId, "This tape has not expired\n");
index 1d86c58ca337775b9140423cbae80ef09565a18f..b7afd3d68cfcf233ec72ba132143fd0c5ee65783 100644 (file)
@@ -222,7 +222,7 @@ PerformDumpTest(TestInfo * tip)
     }
 
     memset(&label, 0, sizeof(label));
-    gettimeofday(&tp, 0);
+    gettimeofday(&tp, NULL);
     label.structVersion = CUR_TAPE_VERSION;
     label.creationTime = tp.tv_sec;
     label.size = info.tapeSize;
index b1ee9cdfe2059128450dcc397cbff7aa2f8d7a93..5a1690aedebe6d043256512d640912674dcd6847 100755 (executable)
@@ -979,7 +979,7 @@ gensym(const char *x)
     char *symbol;
     if (!gensym_n) {
        struct timeval tv;
-       gettimeofday(&tv, (void *)0);
+       gettimeofday(&tv, NULL);
        gensym_n = (tv.tv_sec % 10000) * 100 + tv.tv_usec / 10000;
     }
     symbol = (char *)malloc(32 * sizeof(char));
index 8dc0fe3014d3baf4525b51a9b636bc39b839b158..5da46efbd2e16da85e9b9c91222f70a34ec91365 100644 (file)
@@ -110,7 +110,7 @@ get_time(Date *timeP,
     int i;
     afs_int32 to;
 
-    gettimeofday(&time, 0);
+    gettimeofday(&time, NULL);
     bit = (random_value[3] >> 31) & 1; /* get high bit of high word */
     for (i = 0; i < 4; i++) {
        nbit = random_value[i] >> 31;
@@ -216,7 +216,7 @@ initialize_database(struct ubik_trans *tt)
     struct ktc_encryptionKey key;
     int code;
 
-    gettimeofday((struct timeval *)&key, 0);   /* this is just a cheap seed key */
+    gettimeofday((struct timeval *)&key, NULL);        /* this is just a cheap seed key */
     DES_set_odd_parity(ktc_to_cblock(&key));
     DES_init_random_number_generator(ktc_to_cblock(&key));
     if ((code = DES_new_random_key(ktc_to_cblock(&key)))
index 0304c8b4abe8c42f32bd6631e0b1aa09c409f160..f20dea47d01541a958e60c62e3391241b89f4f09 100644 (file)
@@ -146,14 +146,13 @@ Log(char *fmt, ...)
 {
     va_list args;
     struct timeval now;
-    struct timezone tz;
     struct tm *ltime;
     time_t tt;
     int code;
     PROCESS pid;
     extern char *program;
 
-    code = gettimeofday(&now, &tz);
+    code = gettimeofday(&now, NULL);
     assert(code == 0);
 
     tt = now.tv_sec;
index f7f6d7955c9821701524fce72daf5c6140cd0a77..42069deebc772aa7f5648c3741f34acd3b8b0fc7 100644 (file)
@@ -7419,14 +7419,14 @@ MakeDebugCall(osi_socket socket, afs_uint32 remoteAddr, afs_uint16 remotePort,
                   (struct sockaddr *)&taddr, sizeof(struct sockaddr_in));
 
        /* see if there's a packet available */
-       gettimeofday(&tv_wake,0);
+       gettimeofday(&tv_wake, NULL);
        tv_wake.tv_sec += waitTime;
        for (;;) {
            FD_ZERO(&imask);
            FD_SET(socket, &imask);
            tv_delta.tv_sec = tv_wake.tv_sec;
            tv_delta.tv_usec = tv_wake.tv_usec;
-           gettimeofday(&tv_now, 0);
+           gettimeofday(&tv_now, NULL);
 
            if (tv_delta.tv_usec < tv_now.tv_usec) {
                /* borrow */
index b363aac5c042938277df02c7b1fcc483c155cd99..6fc0acebafd36e3185d089f099c7211b3a77d92a 100644 (file)
@@ -105,7 +105,7 @@ nowms()
     struct timeval tv;
     long temp;
 
-    gettimeofday(&tv, 0);
+    gettimeofday(&tv, NULL);
     temp = ((tv.tv_sec & 0xffff) * 1000) + (tv.tv_usec / 1000);
     return temp;
 }
index 4aefaeeb632d1e74cd021820de97a4d06c47fe2b..24a81ae978f155d4786c1fb393c7377db7b13049 100644 (file)
@@ -769,16 +769,16 @@ main()
        int i;
 
        fc_keysched(key1, sched);
-       gettimeofday(&start, 0);
+       gettimeofday(&start, NULL);
        for (i = 0; i < 1000000; i++)
            fc_keysched(key1, sched);
-       gettimeofday(&stop, 0);
+       gettimeofday(&stop, NULL);
        printf("fc_keysched    = %2.2f us\n",
               (stop.tv_sec - start.tv_sec +
                (stop.tv_usec - start.tv_usec) / 1e6) * 1);
 
        fc_ecb_encrypt(data, data, sched, ENCRYPT);
-       gettimeofday(&start, 0);
+       gettimeofday(&start, NULL);
        for (i = 0; i < 1000000; i++)
            fc_ecb_encrypt(data, data, sched, ENCRYPT);
        gettimeofday(&stop, 0);
@@ -788,11 +788,11 @@ main()
 
        fc_cbc_encrypt(the_quick, ciph, sizeof(the_quick), sched, iv,
                       ENCRYPT);
-       gettimeofday(&start, 0);
+       gettimeofday(&start, NULL);
        for (i = 0; i < 100000; i++)
            fc_cbc_encrypt(the_quick, ciph, sizeof(the_quick), sched, iv,
                           ENCRYPT);
-       gettimeofday(&stop, 0);
+       gettimeofday(&stop, NULL);
        printf("fc_cbc_encrypt = %2.2f us\n",
               (stop.tv_sec - start.tv_sec +
                (stop.tv_usec - start.tv_usec) / 1e6) * 10);
index bff1363b3f9bfdc27567004de5939c42d09dbc0b..162f4949d6df6d44ae562df44f4675816676ca1c 100644 (file)
@@ -159,30 +159,30 @@ main(void)
        int i;
 
        fc_keysched((struct ktc_encryptionKey *)key1, sched);
-       gettimeofday(&start, 0);
+       gettimeofday(&start, NULL);
        for (i = 0; i < 1000000; i++)
            fc_keysched((struct ktc_encryptionKey *)key1, sched);
-       gettimeofday(&stop, 0);
+       gettimeofday(&stop, NULL);
        printf("fc_keysched    = %2.2f us\n",
               (stop.tv_sec - start.tv_sec +
                (stop.tv_usec - start.tv_usec) / 1e6) * 1);
 
        fc_ecb_encrypt(data, data, sched, ENCRYPT);
-       gettimeofday(&start, 0);
+       gettimeofday(&start, NULL);
        for (i = 0; i < 1000000; i++)
            fc_ecb_encrypt(data, data, sched, ENCRYPT);
-       gettimeofday(&stop, 0);
+       gettimeofday(&stop, NULL);
        printf("fc_ecb_encrypt = %2.2f us\n",
               (stop.tv_sec - start.tv_sec +
                (stop.tv_usec - start.tv_usec) / 1e6) * 1);
 
        fc_cbc_encrypt(the_quick, ciph, sizeof(the_quick), sched, iv,
                       ENCRYPT);
-       gettimeofday(&start, 0);
+       gettimeofday(&start, NULL);
        for (i = 0; i < 100000; i++)
            fc_cbc_encrypt(the_quick, ciph, sizeof(the_quick), sched, iv,
                           ENCRYPT);
-       gettimeofday(&stop, 0);
+       gettimeofday(&stop, NULL);
        printf("fc_cbc_encrypt = %2.2f us\n",
               (stop.tv_sec - start.tv_sec +
                (stop.tv_usec - start.tv_usec) / 1e6) * 10);
index fb026f3178868e66c97938c98507568c1c9ee7c8..f5d8d0f96f924a4e6d0c67815545f46a9fa098c1 100644 (file)
@@ -378,7 +378,7 @@ static double
 ftime(void)
 {
     struct timeval tv;
-    gettimeofday(&tv, 0);
+    gettimeofday(&tv, NULL);
     return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
 }
 
index 0568439157a94935ac56c5029f1434bf749edb4e..5175e1ba1c0a277a629d77f5d0a718e9f5b46e46 100644 (file)
@@ -210,7 +210,6 @@ main(int argc, char **argv)
     int filesz = 0;
     int ch, blksize, bytesremaining, bytes;
     struct timeval start, finish;
-    struct timezone tz;
     struct rx_securityClass *ssc = 0, *dsc = 0;
     int sscindex, dscindex;
     struct rx_connection *sconn = NULL, *dconn = NULL;
@@ -433,7 +432,7 @@ main(int argc, char **argv)
        scall = rx_NewCall(sconn);
     if (!dlcl && !unlock)
        dcall = rx_NewCall(dconn);
-    gettimeofday(&start, &tz);
+    gettimeofday(&start, NULL);
     if (unlock) {
        if (fst.lockCount) {
            printf("Sending 1 unlock for %s (%d locks)\n", srcf, fst.lockCount);
@@ -553,7 +552,7 @@ main(int argc, char **argv)
     if (storecode)
        printf("Error returned from store: %s\n", afs_error_message(storecode));
 Finish:
-    gettimeofday(&finish, &tz);
+    gettimeofday(&finish, NULL);
 
     if (!slcl) {
        theFids.AFSCBFids_len = 1;
index 33c124e1905ef41ac21bd95b29e4dd43ea195de5..ef8746dcbf0b252e3b28f83af8c4350745ba14f8 100644 (file)
@@ -92,7 +92,6 @@ static int CBServiceNeeded = 0;
 static struct timeval starttime, opentime, readtime, writetime;
 afs_uint64 xfered=0, oldxfered=0;
 static struct timeval now;
-struct timezone Timezone;
 static float seconds, datarate, oldseconds;
 extern int rxInitDone;
 #ifdef AFS_NT40_ENV
@@ -944,7 +943,7 @@ readFile(struct cmd_syndesc *as, void *unused)
     CBServiceNeeded = 1;
     InitializeCBService();
 
-    gettimeofday (&starttime, &Timezone);
+    gettimeofday (&starttime, NULL);
     fname = as->parms[0].items->data;
     cell = 0;
     if (as->parms[1].items)
@@ -991,7 +990,7 @@ readFile(struct cmd_syndesc *as, void *unused)
                   useHost, fname, code);
           continue;
        }
-        gettimeofday(&opentime, &Timezone);
+        gettimeofday(&opentime, NULL);
        if (verbose) {
             seconds = (float)(opentime.tv_sec + opentime.tv_usec *.000001
                -starttime.tv_sec - starttime.tv_usec *.000001);
@@ -1057,7 +1056,7 @@ readFile(struct cmd_syndesc *as, void *unused)
                    write(1, buf, len);
                length -= len;
                xfered += len;
-               gettimeofday(&now, &Timezone);
+               gettimeofday(&now, NULL);
                if (verbose)
                    printDatarate();
            }
@@ -1069,7 +1068,7 @@ readFile(struct cmd_syndesc *as, void *unused)
        }
         break;
     }
-    gettimeofday(&readtime, &Timezone);
+    gettimeofday(&readtime, NULL);
     if (worstCode) {
        fprintf(stderr,"%s failed with code %d\n",
                (char *) &as->name, worstCode);
@@ -1186,7 +1185,7 @@ writeFile(struct cmd_syndesc *as, void *unused)
        return ENOENT;
     }
     cl = FindCell(cell);
-    gettimeofday (&starttime, &Timezone);
+    gettimeofday (&starttime, NULL);
     useHost = hosts[0];
     RXConn = FindRXConnection(useHost, htons(AFSCONF_FILEPORT), 1,
                              cl->sc, cl->scIndex);
@@ -1253,7 +1252,7 @@ writeFile(struct cmd_syndesc *as, void *unused)
        previous = tbuf;
        Len += tbuf->used;
     }
-    gettimeofday(&opentime, &Timezone);
+    gettimeofday(&opentime, NULL);
     if (verbose) {
         seconds = (float) (opentime.tv_sec + opentime.tv_usec *.000001
            -starttime.tv_sec - starttime.tv_usec *.000001);
@@ -1296,7 +1295,7 @@ writeFile(struct cmd_syndesc *as, void *unused)
                    break;
                }
                xfered += tbuf->used;
-               gettimeofday(&now, &Timezone);
+               gettimeofday(&now, NULL);
                if (verbose)
                    printDatarate();
                length -= tbuf->used;
@@ -1352,7 +1351,7 @@ writeFile(struct cmd_syndesc *as, void *unused)
             }
         }
     }
-    gettimeofday(&writetime, &Timezone);
+    gettimeofday(&writetime, NULL);
     if (worstCode) {
        fprintf(stderr,"%s failed with code %d\n", as->name, worstCode);
     } else if(verbose) {
index f017392d34cf258cef2cd1c44554c73d5c755f47..25aa463f65aa10d9c998cf9441c19d1d2945f026 100644 (file)
@@ -2452,7 +2452,7 @@ SalvageHeader(struct SalvInfo *salvinfo, struct afs_inode_info *sp,
            header.volumeInfo.uniquifier = (isp->maxUniquifier + 1) + 1000;
            header.volumeInfo.type = (isp->volumeId == isp->RWvolumeId ? readwriteVolume : readonlyVolume);     /* XXXX */
            header.volumeInfo.needsCallback = 0;
-           gettimeofday(&tp, 0);
+           gettimeofday(&tp, NULL);
            header.volumeInfo.creationDate = tp.tv_sec;
            nBytes =
                FDH_PWRITE(fdP, (char *)&header.volumeInfo,
@@ -4736,7 +4736,7 @@ Log(const char *format, ...)
     } else
 #endif
        if (logFile) {
-           gettimeofday(&now, 0);
+           gettimeofday(&now, NULL);
            fprintf(logFile, "%s %s", TimeStamp(now.tv_sec, 1), tmp);
            fflush(logFile);
        }
index 10d19bfdf7192343ad53b9fa27ab9fb6d6d0c28b..599d4c9948ca3b2c2b5db43c0e961ef54b667232 100644 (file)
@@ -54,7 +54,6 @@ NewTrans(afs_uint32 avol, afs_int32 apart)
     /* set volid, next, partition */
     struct volser_trans *tt, *newtt;
     struct timeval tp;
-    struct timezone tzp;
 
     newtt = (struct volser_trans *)malloc(sizeof(struct volser_trans));
     VTRANS_LOCK;
@@ -73,7 +72,7 @@ NewTrans(afs_uint32 avol, afs_int32 apart)
     tt->refCount = 1;
     tt->rxCallPtr = (struct rx_call *)0;
     strcpy(tt->lastProcName, "");
-    gettimeofday(&tp, &tzp);
+    gettimeofday(&tp, NULL);
     tt->creationTime = tp.tv_sec;
     tt->time = FT_ApproxTime();
     tt->tid = transCounter++;