From 2386f5741d284a449f0260b91cde65209dc3c2bd Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Tue, 5 Apr 2011 14:51:26 -0500 Subject: [PATCH] Correct strftime callers Some strftime callers were not using the resultant string appropriately. Correct them to have the same behavior as when we were using afs_ctime (which included a trailing newline). Change-Id: I1d23a6a06460cae3d2a253c9f084c22324fc7542 Reviewed-on: http://gerrit.openafs.org/4437 Reviewed-by: Derrick Brashear Reviewed-by: Simon Wilkinson Tested-by: BuildBot --- src/util/assert.c | 2 +- src/util/serverLog.c | 2 +- src/viced/host.c | 10 +++++----- src/viced/viced.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/util/assert.c b/src/util/assert.c index 03af01b49..78e9d0ce5 100644 --- a/src/util/assert.c +++ b/src/util/assert.c @@ -35,7 +35,7 @@ AssertionFailed(char *file, int line) when = time(NULL); strftime(tdate, sizeof(tdate), "%a %b %d %T %Y", localtime_r(&when, &tm)); - fprintf(stderr, "%sAssertion failed! file %s, line %d.\n", tdate, file, + fprintf(stderr, "%s Assertion failed! file %s, line %d.\n", tdate, file, line); fflush(stderr); afs_abort(); diff --git a/src/util/serverLog.c b/src/util/serverLog.c index 710502c37..ee69e0fc2 100644 --- a/src/util/serverLog.c +++ b/src/util/serverLog.c @@ -109,7 +109,7 @@ vFSLog(const char *format, va_list args) currenttime = time(NULL); len = strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y ", localtime_r(¤ttime, &tm)); - info = &tbuffer[len+1]; + info = &tbuffer[len]; if (mrafsStyleLogs || threadIdLogs) { num = (*threadNumProgram) (); diff --git a/src/viced/host.c b/src/viced/host.c index 7d12aa36a..9b27d2fc5 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -2743,7 +2743,7 @@ h_PrintClient(struct host *host, int flags, void *rock) } strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y", localtime_r(&LastCall, &tm)); - snprintf(tmpStr, sizeof tmpStr, "Host %s:%d down = %d, LastCall %s", + snprintf(tmpStr, sizeof tmpStr, "Host %s:%d down = %d, LastCall %s\n", afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), (host->hostFlags & VENUSDOWN), tbuffer); @@ -2754,11 +2754,11 @@ h_PrintClient(struct host *host, int flags, void *rock) strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y", localtime_r(&expTime, &tm)); snprintf(tmpStr, sizeof tmpStr, - " user id=%d, name=%s, sl=%s till %s", + " user id=%d, name=%s, sl=%s till %s\n", client->ViceId, h_UserName(client), client->authClass ? "Authenticated" : "Not authenticated", - client->authClass ? tbuffer : "No Limit\n"); + client->authClass ? tbuffer : "No Limit"); (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file); snprintf(tmpStr, sizeof tmpStr, " CPS-%d is [", client->CPS.prlist_len); @@ -2804,7 +2804,7 @@ h_PrintClients(void) now = FT_ApproxTime(); strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y", localtime_r(&now, &tm)); - snprintf(tmpStr, sizeof tmpStr, "List of active users at %s\n", + snprintf(tmpStr, sizeof tmpStr, "List of active users at %s\n\n", tbuffer); (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file); h_Enumerate(h_PrintClient, (char *)file); @@ -2878,7 +2878,7 @@ h_DumpHosts(void) now = FT_ApproxTime(); strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y", localtime_r(&now, &tm)); - snprintf(tmpStr, sizeof tmpStr, "List of active hosts at %s\n", tbuffer); + snprintf(tmpStr, sizeof tmpStr, "List of active hosts at %s\n\n", tbuffer); (void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file); h_Enumerate(h_DumpHost, (char *)file); STREAM_REALLYCLOSE(file); diff --git a/src/viced/viced.c b/src/viced/viced.c index fa7e3c603..aabe7a3f6 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -815,7 +815,7 @@ ShutDownAndCore(int dopanic) strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y", localtime_r(&now, &tm)); - ViceLog(0, ("Shutting down file server at %s", tbuffer)); + ViceLog(0, ("Shutting down file server at %s\n", tbuffer)); if (dopanic) ViceLog(0, ("ABNORMAL SHUTDOWN, see core file.\n")); DFlush(); @@ -2385,7 +2385,7 @@ main(int argc, char *argv[]) t = tp.tv_sec; strftime(tbuffer, sizeof(tbuffer), "%a %b %d %T %Y", localtime_r(&t, &tm)); - ViceLog(0, ("File Server started %s", tbuffer)); + ViceLog(0, ("File Server started %s\n", tbuffer)); #if FS_STATS_DETAILED afs_FullPerfStats.det.epoch.tv_sec = StartTime = tp.tv_sec; #endif -- 2.39.5