Module Name: src Committed By: joerg Date: Thu Jan 2 18:26:03 UTC 2014
Modified Files: src/external/bsd/ntp/dist/libntp: prettydate.c Log Message: Use separate variables for the format strings to get working format string checking with both GCC and Clang. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/ntp/dist/libntp/prettydate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/bsd/ntp/dist/libntp/prettydate.c diff -u src/external/bsd/ntp/dist/libntp/prettydate.c:1.2 src/external/bsd/ntp/dist/libntp/prettydate.c:1.3 --- src/external/bsd/ntp/dist/libntp/prettydate.c:1.2 Sat Dec 28 03:20:13 2013 +++ src/external/bsd/ntp/dist/libntp/prettydate.c Thu Jan 2 18:26:03 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: prettydate.c,v 1.2 2013/12/28 03:20:13 christos Exp $ */ +/* $NetBSD: prettydate.c,v 1.3 2014/01/02 18:26:03 joerg Exp $ */ /* * prettydate - convert a time stamp to something readable @@ -159,10 +159,10 @@ common_prettydate( int local ) { - static const char* pfmt[2] = { - "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03u", - "%08lx.%08lx [%s, %s %2d %4d %2d:%02d:%02d.%03u UTC]" - }; + static const char pfmt0[] = + "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03u"; + static const char pfmt1[] = + "%08lx.%08lx [%s, %s %2d %4d %2d:%02d:%02d.%03u UTC]"; char *bp; struct tm *tm; @@ -188,13 +188,13 @@ common_prettydate( */ struct calendar jd; ntpcal_time_to_date(&jd, &sec); - snprintf(bp, LIB_BUFLENGTH, pfmt[local != 0], + snprintf(bp, LIB_BUFLENGTH, local ? pfmt1 : pfmt0, (u_long)ts->l_ui, (u_long)ts->l_uf, daynames[jd.weekday], months[jd.month-1], jd.monthday, jd.year, jd.hour, jd.minute, jd.second, msec); } else - snprintf(bp, LIB_BUFLENGTH, pfmt[0], + snprintf(bp, LIB_BUFLENGTH, pfmt0, (u_long)ts->l_ui, (u_long)ts->l_uf, daynames[tm->tm_wday], months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year, tm->tm_hour,