From: Jeffrey Altman Date: Wed, 8 Sep 2004 22:35:33 +0000 (+0000) Subject: time_t-pointer-conversions-20040908 X-Git-Tag: BP-disconnected~250 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=24da12afa3b7b79b4af097daa39b98093e10a743;p=packages%2Fo%2Fopenafs.git time_t-pointer-conversions-20040908 FIXES 15169 Modify all parameters to functions which take a pointer to time_t to actually provide a pointer to time_t instead of pointers to long, afs_int32, afs_uint32, etc. This is to provide compatibility with systems that use 64-bit time_t typedefs such as the IBM compilers for AIX and the Microsoft Visual Studio 2005 compiler. This patch does not address any of the issues of data loss caused by converting 64-bit time_t to 32-bit signed or unsigned values. --- diff --git a/src/WINNT/afsd/cm_freelance.c b/src/WINNT/afsd/cm_freelance.c index f0caaf3db..a4b85999d 100644 --- a/src/WINNT/afsd/cm_freelance.c +++ b/src/WINNT/afsd/cm_freelance.c @@ -30,7 +30,7 @@ cm_localMountPoint_t* cm_localMountPoints; osi_mutex_t cm_Freelance_Lock; int cm_localMountPointChangeFlag = 0; int cm_freelanceEnabled = 0; -afs_uint32 FakeFreelanceModTime = 0x3b49f6e2; +time_t FakeFreelanceModTime = 0x3b49f6e2; void cm_InitFakeRootDir(); diff --git a/src/WINNT/afsd/cm_freelance.h b/src/WINNT/afsd/cm_freelance.h index b7d90e3e7..33874a24c 100644 --- a/src/WINNT/afsd/cm_freelance.h +++ b/src/WINNT/afsd/cm_freelance.h @@ -23,5 +23,5 @@ extern int cm_clearLocalMountPointChange(); #define AFS_FAKE_ROOT_CELL_ID 0xFFFFFFFF #define AFS_FAKE_ROOT_VOL_ID 0xFFFFFFFF -extern afs_uint32 FakeFreelanceModTime; +extern time_t FakeFreelanceModTime; #endif // _CM_FREELANCE_H diff --git a/src/WINNT/afsd/cm_vnodeops.h b/src/WINNT/afsd/cm_vnodeops.h index ce45999f1..058c541b2 100644 --- a/src/WINNT/afsd/cm_vnodeops.h +++ b/src/WINNT/afsd/cm_vnodeops.h @@ -15,7 +15,7 @@ extern unsigned int cm_mountRootGen; /* parms for attribute setting call */ typedef struct cm_attr { int mask; - unsigned long clientModTime; + time_t clientModTime; osi_hyper_t length; int unixModeBits; long owner; diff --git a/src/WINNT/afsd/ctokens.c b/src/WINNT/afsd/ctokens.c index 9b357d9ae..5d74150fd 100644 --- a/src/WINNT/afsd/ctokens.c +++ b/src/WINNT/afsd/ctokens.c @@ -88,7 +88,8 @@ main(argc, argv) if (tokenExpireTime <= current_time) printf("[>> Expired <<]\n"); else { - expireString = ctime(&tokenExpireTime); + time_t t = tokenExpireTime; + expireString = ctime(&t); expireString += 4; /* Skip day of week */ expireString[12] = '\0'; /* Omit secs & year */ printf("[Expires %s]\n", expireString); diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index 7d0f37d2c..65781133a 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -5800,8 +5800,8 @@ long smb_ReceiveCoreCreate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) code = cm_SetAttr(scp, &setAttr, userp, &req); } else { - setAttr.mask = CM_ATTRMASK_CLIENTMODTIME; - smb_UnixTimeFromDosUTime(&setAttr.clientModTime, dosTime); + setAttr.mask = CM_ATTRMASK_CLIENTMODTIME; + smb_UnixTimeFromDosUTime(&setAttr.clientModTime, dosTime); code = cm_Create(dscp, lastNamep, 0, &setAttr, &scp, userp, &req); if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH)) diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 5b43ef969..ede718e92 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -2006,7 +2006,7 @@ long smb_ReceiveTran2Open(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op) smb_fid_t *fidp; int attributes; char *lastNamep; - long dosTime; + time_t dosTime; int openFun; int trunc; int openMode; @@ -2476,7 +2476,7 @@ long cm_GetShortName(char *pathp, cm_user_t *userp, cm_req_t *reqp, long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *opx) { smb_tran2Packet_t *outp; - unsigned long dosTime; + time_t dosTime; FILETIME ft; unsigned short infoLevel; int nbytesRequired; @@ -2980,7 +2980,7 @@ long smb_ApplyV3DirListPatches(cm_scache_t *dscp, cm_scache_t *scp; cm_scache_t *targetScp; /* target if scp is a symlink */ char *dptr; - long dosTime; + time_t dosTime; FILETIME ft; int shortTemp; unsigned short attr; @@ -4067,7 +4067,7 @@ long smb_ReceiveV3OpenX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) smb_fid_t *fidp; int attributes; char *lastNamep; - long dosTime; + time_t dosTime; int openFun; int trunc; int openMode; @@ -4458,7 +4458,7 @@ long smb_ReceiveV3GetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t * smb_fid_t *fidp; cm_scache_t *scp; long code = 0; - long searchTime; + time_t searchTime; cm_user_t *userp; cm_req_t req; @@ -4520,8 +4520,8 @@ long smb_ReceiveV3SetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t * smb_fid_t *fidp; cm_scache_t *scp; long code = 0; - long searchTime; - long unixTime; + time_t searchTime; + time_t unixTime; cm_user_t *userp; cm_attr_t attrs; cm_req_t req; diff --git a/src/bucoord/commands.c b/src/bucoord/commands.c index 423de31bd..49c08773a 100644 --- a/src/bucoord/commands.c +++ b/src/bucoord/commands.c @@ -626,7 +626,8 @@ compactDateString(date_long, string, size) if (*date_long == NEVERDATE) { sprintf(string, "NEVER"); } else { - ltime = localtime(date_long); + time_t t = *date_long; + ltime = localtime(&t); /* prints date in U.S. format of mm/dd/yyyy */ strftime(string, size, "%m/%d/%Y %H:%M", ltime); } @@ -2902,13 +2903,14 @@ dumpInfo(dumpid, detailFlag) printf("----\n"); printDumpEntry(&dumpEntry); } else { + time_t t = dumpEntry.created; if (dbDump) printf("Dump: id %u, created: %s\n", dumpEntry.id, - ctime(&dumpEntry.created)); - else + ctime(&t)); + else printf("Dump: id %u, level %d, volumes %d, created: %s\n", dumpEntry.id, dumpEntry.level, dumpEntry.nVolumes, - ctime(&dumpEntry.created)); + ctime(&t)); } if (!detailFlag && (strlen(dumpEntry.tapes.tapeServer) > 0) diff --git a/src/bucoord/dump_sched.c b/src/bucoord/dump_sched.c index fcf76f7b0..f99db4159 100644 --- a/src/bucoord/dump_sched.c +++ b/src/bucoord/dump_sched.c @@ -581,7 +581,8 @@ ListDumpSchedule(adump, alevel) case BC_ABS_EXPDATE: /* absolute expiration date. Never expires if date is 0 */ if (adump->expDate) { - printf("expires at %.24s", cTIME(&adump->expDate)); + time_t t = adump->expDate; + printf("expires at %.24s", cTIME(&t)); } break; diff --git a/src/bucoord/restore.c b/src/bucoord/restore.c index 122291127..513de7ea9 100644 --- a/src/bucoord/restore.c +++ b/src/bucoord/restore.c @@ -195,7 +195,7 @@ bc_Restorer(aindex) afs_int32 partitionAll; /* Likewise for partition */ struct hostent *hostPtr; long haddr; - u_long did; + time_t did; int foundtape, c; extern statusP createStatusNode(); diff --git a/src/butc/lwps.c b/src/butc/lwps.c index 1ce9e4120..534ab48b4 100644 --- a/src/butc/lwps.c +++ b/src/butc/lwps.c @@ -2287,6 +2287,7 @@ PrintTapeLabel(labelptr) struct butm_tapeLabel *labelptr; { char tapeName[BU_MAXTAPELEN + 32]; + time_t t; printf("Tape label\n"); printf("----------\n"); @@ -2294,9 +2295,12 @@ PrintTapeLabel(labelptr) printf("permanent tape name = %s\n", tapeName); TAPENAME(tapeName, labelptr->AFSName, labelptr->dumpid); printf("AFS tape name = %s\n", tapeName); - printf("creationTime = %s", ctime(&labelptr->creationTime)); - if (labelptr->expirationDate) - printf("expirationDate = %s", cTIME(&labelptr->expirationDate)); + t = labelptr->creationTime; + printf("creationTime = %s", ctime(&t)); + if (labelptr->expirationDate) { + t = labelptr->expirationDate; + printf("expirationDate = %s", cTIME(&t)); + } printf("cell = %s\n", labelptr->cell); printf("size = %u Kbytes\n", labelptr->size); printf("dump path = %s\n", labelptr->dumpPath); diff --git a/src/butc/recoverDb.c b/src/butc/recoverDb.c index 1b66eb9c6..11c53b35e 100644 --- a/src/butc/recoverDb.c +++ b/src/butc/recoverDb.c @@ -59,6 +59,7 @@ PrintDumpLabel(labelptr) struct butm_tapeLabel *labelptr; { char tapeName[BU_MAXTAPELEN + 32]; + time_t t; printf("Dump label\n"); printf("----------\n"); @@ -66,9 +67,12 @@ PrintDumpLabel(labelptr) printf("permanent tape name = %s\n", tapeName); TAPENAME(tapeName, labelptr->AFSName, labelptr->dumpid); printf("AFS tape name = %s\n", tapeName); - printf("creationTime = %s", ctime(&labelptr->creationTime)); - if (labelptr->expirationDate) - printf("expirationDate = %s", cTIME(&labelptr->expirationDate)); + t = labelptr->creationTime; + printf("creationTime = %s", ctime(&t)); + if (labelptr->expirationDate) { + t = labelptr->expirationDate; + printf("expirationDate = %s", cTIME(&t)); + } printf("cell = %s\n", labelptr->cell); printf("size = %u Kbytes\n", labelptr->size); printf("dump path = %s\n", labelptr->dumpPath); @@ -87,6 +91,8 @@ static PrintVolumeHeader(volHeader) struct volumeHeader *volHeader; { + time_t t; + printf("-- volume --\n"); printf("volume name: %s\n", volHeader->volumeName); printf("volume ID %d\n", volHeader->volumeID); @@ -97,7 +103,8 @@ PrintVolumeHeader(volHeader) printf("parentID %d\n", volHeader->parentID); printf("endTime %d\n", volHeader->endTime); /* printf("versionflags %d\n", volHeader->versionflags); */ - printf("clonedate %s\n", ctime(&volHeader->cloneDate)); + t = volHeader->cloneDate; + printf("clonedate %s\n", ctime(&t)); } /* Ask diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c index d804794f6..787fa8da3 100644 --- a/src/butc/tcmain.c +++ b/src/butc/tcmain.c @@ -856,6 +856,7 @@ WorkerBee(as, arock) #else PROCESS dbWatcherPid; #endif + time_t t; debugLevel = 0; @@ -1131,7 +1132,8 @@ WorkerBee(as, arock) TLog(0, "Starting Tape Coordinator: Port offset %u Debug level %u\n", portOffset, debugLevel); - TLog(0, "Token expires: %s\n", cTIME(&ttoken.endTime)); + t = ttoken.endTime; + TLog(0, "Token expires: %s\n", cTIME(&t)); rx_StartServer(1); /* Donate this process to the server process pool */ TLog(0, "Error: StartServer returned"); diff --git a/src/butm/test_ftm.c b/src/butm/test_ftm.c index 973e6f218..f8d1406ae 100644 --- a/src/butm/test_ftm.c +++ b/src/butm/test_ftm.c @@ -324,8 +324,8 @@ PerformDumpTest(TestInfo * tip) } past = time(0) - label.creationTime; if ((past < 0) || (past > 5 * 60)) { - printf("label creation time is long ago: %s\n", - ctime(&label.creationTime)); + time_t t = label.creationTime; + printf("label creation time is long ago: %s\n", ctime(&t)); ERROR_EXIT(5); } if (strcmp(label.AFSName, tip->tapeName) != 0) { diff --git a/src/ubik/udebug.c b/src/ubik/udebug.c index 2499ff7b6..b72ad85cf 100644 --- a/src/ubik/udebug.c +++ b/src/ubik/udebug.c @@ -97,7 +97,7 @@ CommandProc(struct cmd_syndesc *as, char *arock) register afs_int32 i, j, code; short port; int int32p; - afs_int32 now, diff, newtime; + time_t now, diff, newtime; struct hostent *th; struct rx_connection *tconn; struct rx_securityClass *sc; diff --git a/src/util/ktime.c b/src/util/ktime.c index eba0260b9..f113b4f01 100644 --- a/src/util/ktime.c +++ b/src/util/ktime.c @@ -165,7 +165,8 @@ ktime_DateOf(afs_int32 atime) { static char tbuffer[30]; register char *tp; - tp = ctime((time_t *) & atime); + time_t t = atime; + tp = ctime(&t); if (tp) { strcpy(tbuffer, tp); tbuffer[24] = 0; /* get rid of new line */ diff --git a/src/util/serverLog.c b/src/util/serverLog.c index fabf52090..7b63bff58 100644 --- a/src/util/serverLog.c +++ b/src/util/serverLog.c @@ -235,8 +235,9 @@ OpenLog(const char *fileName) #endif if (mrafsStyleLogs) { + time_t t = Start.tv_sec; TM_GetTimeOfDay(&Start, 0); - TimeFields = localtime(&Start.tv_sec); + TimeFields = localtime(&t); if (fileName) { if (strncmp(fileName, (char *)&ourName, strlen(fileName))) strcpy((char *)&ourName, (char *)fileName); diff --git a/src/viced/viced.c b/src/viced/viced.c index ba1097239..e2251bc17 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -1564,6 +1564,7 @@ main(int argc, char *argv[]) struct rlimit rlim; /* max number of open file descriptors */ #endif int curLimit; + time_t t; #ifdef AFS_AIX32_ENV struct sigaction nsa; @@ -1868,9 +1869,10 @@ main(int argc, char *argv[]) TM_GetTimeOfDay(&tp, 0); #ifndef AFS_QUIETFS_ENV - if (console != NULL) { + if (console != NULL) { + time_t t = tp.tv_sec; fprintf(console, "File server has started at %s\r", - afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer))); + afs_ctime(&t, tbuffer, sizeof(tbuffer))); } #endif @@ -1907,9 +1909,10 @@ main(int argc, char *argv[]) (void)signal(SIGQUIT, ShutDown_Signal); #endif + t = tp.tv_sec; ViceLog(0, ("File Server started %s", - afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer)))); + afs_ctime(&t, tbuffer, sizeof(tbuffer)))); #if FS_STATS_DETAILED afs_FullPerfStats.det.epoch.tv_sec = StartTime = tp.tv_sec; #endif