svn commit: r300338 - projects/zfsd/head/lib/libdevdctl
Alan Somers
asomers at FreeBSD.org
Sat May 21 00:34:56 UTC 2016
Author: asomers
Date: Sat May 21 00:34:54 2016
New Revision: 300338
URL: https://svnweb.freebsd.org/changeset/base/300338
Log:
Fix zfsd where the timezone is not UTC
lib/libdevdctl/event.cc
Fix a logic error in Event::TimestampEventString that was
timestamping events in the local timezone instead of UTC. Also,
simplify the code a bit.
Sponsored by: Spectra Logic Corp
Modified:
projects/zfsd/head/lib/libdevdctl/event.cc
Modified: projects/zfsd/head/lib/libdevdctl/event.cc
==============================================================================
--- projects/zfsd/head/lib/libdevdctl/event.cc Fri May 20 23:28:43 2016 (r300337)
+++ projects/zfsd/head/lib/libdevdctl/event.cc Sat May 21 00:34:54 2016 (r300338)
@@ -41,7 +41,6 @@
#include <sys/filio.h>
#include <sys/param.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <err.h>
#include <fcntl.h>
@@ -50,6 +49,7 @@
#include <syslog.h>
#include <unistd.h>
+#include <cinttypes>
#include <cstdarg>
#include <cstring>
#include <iostream>
@@ -430,14 +430,13 @@ Event::TimestampEventString(std::string
if (eventString.find("timestamp=") == string::npos) {
const size_t bufsize = 32; // Long enough for a 64-bit int
timeval now;
- struct tm* time_s;
char timebuf[bufsize];
size_t eventEnd(eventString.find_last_not_of('\n') + 1);
if (gettimeofday(&now, NULL) != 0)
err(1, "gettimeofday");
- time_s = gmtime(&now.tv_sec);
- strftime(timebuf, bufsize, " timestamp=%s", time_s);
+ snprintf(timebuf, bufsize, " timestamp=%"PRId64,
+ (int64_t) now.tv_sec);
eventString.insert(eventEnd, timebuf);
}
}
More information about the svn-src-projects
mailing list