INN commit: trunk (history/his.c innd/art.c)

INN Commit rra at isc.org
Sun Nov 23 21:37:47 UTC 2014


    Date: Sunday, November 23, 2014 @ 13:37:46
  Author: iulius
Revision: 9748

Fix gcc warning on FreeBSD

Casts to time_t * were causing "dereferencing type-punned pointer will
break strict-aliasing rules" warnings on FreeBSD.

Modified:
  trunk/history/his.c
  trunk/innd/art.c

---------------+
 history/his.c |    4 +++-
 innd/art.c    |    6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

Modified: history/his.c
===================================================================
--- history/his.c	2014-11-12 20:58:36 UTC (rev 9747)
+++ history/his.c	2014-11-23 21:37:46 UTC (rev 9748)
@@ -442,12 +442,14 @@
 {
     struct timeval tv;
     struct tm *tm;
+    time_t t;
 
     if (HISfdlog == NULL) /* do nothing unless HISlogto() has been called */
 	return;
 
     gettimeofday(&tv, NULL);
-    tm = localtime((const time_t *)&(tv.tv_sec));
+    t = tv.tv_sec;
+    tm = localtime(&t);
     if (HISstat_start[code].tv_sec != 0) {
 	fprintf(HISfdlog, "%d/%d/%d %02d:%02d:%02d.%06d: [%d] %s (%.6f)\n",
 		tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,

Modified: innd/art.c
===================================================================
--- innd/art.c	2014-11-12 20:58:36 UTC (rev 9747)
+++ innd/art.c	2014-11-23 21:37:46 UTC (rev 9748)
@@ -302,20 +302,22 @@
   const HDRCONTENT *hc = data->HdrContent;
   int i;
   bool Done;
+  time_t t;
 
   TMRstart(TMR_ARTLOG);
   /* We could be a bit faster by not dividing Now.usec by 1000,
    * but who really wants to log at the Microsec level? */
   Done = code == ART_ACCEPT || code == ART_JUNK;
+  t = Now.tv_sec;
   if (text)
     i = fprintf(Log, "%.15s.%03d %c %s %s %s%s",
-      ctime((const time_t *) &Now.tv_sec) + 4, (int)(Now.tv_usec / 1000), code,
+      ctime(&t) + 4, (int)(Now.tv_usec / 1000), code,
       data->Feedsite != NULL ? data->Feedsite : "(null)",
       HDR_FOUND(HDR__MESSAGE_ID) ? HDR(HDR__MESSAGE_ID) : "(null)",
       text, Done ? "" : "\n");
   else
     i = fprintf(Log, "%.15s.%03d %c %s %s%s",
-      ctime((const time_t *) &Now.tv_sec) + 4, (int)(Now.tv_usec / 1000), code,
+      ctime(&t) + 4, (int)(Now.tv_usec / 1000), code,
       data->Feedsite != NULL ? data->Feedsite : "(null)",
       HDR_FOUND(HDR__MESSAGE_ID) ? HDR(HDR__MESSAGE_ID) : "(null)",
       Done ? "" : "\n");



More information about the inn-committers mailing list