From: Jeffrey Altman Date: Wed, 15 Jul 2009 05:32:28 +0000 (-0400) Subject: Do not call ctime() twice in the same statement X-Git-Tag: openafs-devel-1_5_61~112 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a8cd0240e19301673598544166dab639f8e83c10;p=packages%2Fo%2Fopenafs.git Do not call ctime() twice in the same statement Reported by Marcus Watts. Two calls to ctime() in the same fprintf() statement will result in only one of the times being printed twice. This is due to the fact that ctime() returns a static buffer. LICENSE IPL10 Reviewed-on: http://gerrit.openafs.org/85 Verified-by: Russ Allbery Reviewed-by: Russ Allbery --- diff --git a/src/butc/read_tape.c b/src/butc/read_tape.c index 91321a21a..e7f1fad9d 100644 --- a/src/butc/read_tape.c +++ b/src/butc/read_tape.c @@ -154,11 +154,15 @@ printHeader(struct volumeHeader *headerPtr, afs_int32 *isvolheader) if (verbose) fprintf(stderr, "Volume header\n"); fprintf(stderr, - "VOLUME %3d %s (%u) - %s dump from %.24s till %.24s\n", + "VOLUME %3d %s (%u) - %s dump from %.24s", ++volcount, headerPtr->volumeName, headerPtr->volumeID, (headerPtr->level ? "Incr" : "Full"), - ((headerPtr->from) ? (char *)ctime(&headerPtr->from) : "0"), - ctime(&(headerPtr->cloneDate))); + ((headerPtr->from) ? (char *)ctime(&headerPtr->from) : "0")); + /* do not include two ctime() calls in the same fprintf call as + * the same string buffer will be returned by each call. */ + fprintf(stderr, + " till %.24s\n", + ctime(&(headerPtr->cloneDate))); if (printheaders) { fprintf(stderr, " Volume Name = %s\n", headerPtr->volumeName);