From a8cd0240e19301673598544166dab639f8e83c10 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 15 Jul 2009 01:32:28 -0400 Subject: [PATCH] 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 --- src/butc/read_tape.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); -- 2.39.5