The warnings, given by clang with -Wshorten-64-to-32, were:
./util-print.c:306:48: warning: implicit conversion loses integer
precision: 'const __suseconds64_t' (aka 'const long long') to 'long'
[-Wshorten-64-to-32]
ts_date_hmsfrac_print(ndo, tvp->tv_sec, tvp->tv_usec,
~~~~~~~~~~~~~~~~~~~~~ ~~~~~^~~~~~~
./util-print.c:306:35: warning: implicit conversion loses integer
precision: 'const __time64_t' (aka 'const long long') to 'long'
[-Wshorten-64-to-32]
ts_date_hmsfrac_print(ndo, tvp->tv_sec, tvp->tv_usec,
~~~~~~~~~~~~~~~~~~~~~ ~~~~~^~~~~~
./util-print.c:315:40: warning: implicit conversion loses integer
precision: 'const __suseconds64_t' (aka 'const long long') to 'long'
[-Wshorten-64-to-32]
ts_unix_print(ndo, tvp->tv_sec, tvp->tv_usec);
~~~~~~~~~~~~~ ~~~~~^~~~~~~
./util-print.c:315:27: warning: implicit conversion loses integer
precision: 'const __time64_t' (aka 'const long long') to 'long'
[-Wshorten-64-to-32]
ts_unix_print(ndo, tvp->tv_sec, tvp->tv_usec);
~~~~~~~~~~~~~ ~~~~~^~~~~~
./util-print.c:346:58: warning: implicit conversion loses integer
precision: '__suseconds64_t' (aka 'long long') to 'long'
[-Wshorten-64-to-32]
ts_date_hmsfrac_print(ndo, tv_result.tv_sec, tv_result.tv_usec,
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~^~~~~~~
./util-print.c:346:40: warning: implicit conversion loses integer
precision: '__time64_t' (aka 'long long') to 'long'
[-Wshorten-64-to-32]
ts_date_hmsfrac_print(ndo, tv_result.tv_sec, tv_result.tv_usec,
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~^~~~~~
./util-print.c:355:48: warning: implicit conversion loses integer
precision: 'const __suseconds64_t' (aka 'const long long') to 'long'
[-Wshorten-64-to-32]
ts_date_hmsfrac_print(ndo, tvp->tv_sec, tvp->tv_usec,
~~~~~~~~~~~~~~~~~~~~~ ~~~~~^~~~~~~
./util-print.c:355:35: warning: implicit conversion loses integer
precision: 'const __time64_t' (aka 'const long long') to 'long'
[-Wshorten-64-to-32]
ts_date_hmsfrac_print(ndo, tvp->tv_sec, tvp->tv_usec,
~~~~~~~~~~~~~~~~~~~~~ ~~~~~^~~~~~
* Print the timestamp .FRAC part (Microseconds/nanoseconds)
*/
static void
* Print the timestamp .FRAC part (Microseconds/nanoseconds)
*/
static void
-ts_frac_print(netdissect_options *ndo, long usec)
+ts_frac_print(netdissect_options *ndo, const struct timeval *tv)
{
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
switch (ndo->ndo_tstamp_precision) {
case PCAP_TSTAMP_PRECISION_MICRO:
{
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
switch (ndo->ndo_tstamp_precision) {
case PCAP_TSTAMP_PRECISION_MICRO:
- ND_PRINT(".%06u", (unsigned)usec);
+ ND_PRINT(".%06u", (unsigned)tv->tv_usec);
break;
case PCAP_TSTAMP_PRECISION_NANO:
break;
case PCAP_TSTAMP_PRECISION_NANO:
- ND_PRINT(".%09u", (unsigned)usec);
+ ND_PRINT(".%09u", (unsigned)tv->tv_usec);
- ND_PRINT(".%06u", (unsigned)usec);
+ ND_PRINT(".%06u", (unsigned)tv->tv_usec);
* if date_flag == WITH_DATE print YY:MM:DD before HH:MM:SS.FRAC
*/
static void
* if date_flag == WITH_DATE print YY:MM:DD before HH:MM:SS.FRAC
*/
static void
-ts_date_hmsfrac_print(netdissect_options *ndo, long sec, long usec,
+ts_date_hmsfrac_print(netdissect_options *ndo, const struct timeval *tv,
enum date_flag date_flag, enum time_flag time_flag)
{
enum date_flag date_flag, enum time_flag time_flag)
{
struct tm *tm;
char timebuf[32];
const char *timestr;
struct tm *tm;
char timebuf[32];
const char *timestr;
- if ((unsigned)sec & 0x80000000) {
+ if ((unsigned)tv->tv_sec & 0x80000000) {
ND_PRINT("[Error converting time]");
return;
}
if (time_flag == LOCAL_TIME)
ND_PRINT("[Error converting time]");
return;
}
if (time_flag == LOCAL_TIME)
+ tm = localtime(&tv->tv_sec);
+ tm = gmtime(&tv->tv_sec);
if (date_flag == WITH_DATE) {
timestr = nd_format_time(timebuf, sizeof(timebuf),
if (date_flag == WITH_DATE) {
timestr = nd_format_time(timebuf, sizeof(timebuf),
}
ND_PRINT("%s", timestr);
}
ND_PRINT("%s", timestr);
- ts_frac_print(ndo, usec);
+ ts_frac_print(ndo, tv);
}
/*
* Print the timestamp - Unix timeval style, as SECS.FRAC.
*/
static void
}
/*
* Print the timestamp - Unix timeval style, as SECS.FRAC.
*/
static void
-ts_unix_print(netdissect_options *ndo, long sec, long usec)
+ts_unix_print(netdissect_options *ndo, const struct timeval *tv)
- if ((unsigned)sec & 0x80000000) {
+ if ((unsigned)tv->tv_sec & 0x80000000) {
ND_PRINT("[Error converting time]");
return;
}
ND_PRINT("[Error converting time]");
return;
}
- ND_PRINT("%u", (unsigned)sec);
- ts_frac_print(ndo, usec);
+ ND_PRINT("%u", (unsigned)tv->tv_sec);
+ ts_frac_print(ndo, tv);
switch (ndo->ndo_tflag) {
case 0: /* Default */
switch (ndo->ndo_tflag) {
case 0: /* Default */
- ts_date_hmsfrac_print(ndo, tvp->tv_sec, tvp->tv_usec,
- WITHOUT_DATE, LOCAL_TIME);
+ ts_date_hmsfrac_print(ndo, tvp, WITHOUT_DATE, LOCAL_TIME);
break;
case 2: /* Unix timeval style */
break;
case 2: /* Unix timeval style */
- ts_unix_print(ndo, tvp->tv_sec, tvp->tv_usec);
+ ts_unix_print(ndo, tvp);
netdissect_timevalsub(tvp, &tv_ref, &tv_result, nano_prec);
ND_PRINT((negative_offset ? "-" : " "));
netdissect_timevalsub(tvp, &tv_ref, &tv_result, nano_prec);
ND_PRINT((negative_offset ? "-" : " "));
- ts_date_hmsfrac_print(ndo, tv_result.tv_sec, tv_result.tv_usec,
- WITHOUT_DATE, UTC_TIME);
+ ts_date_hmsfrac_print(ndo, &tv_result, WITHOUT_DATE, UTC_TIME);
ND_PRINT(" ");
if (ndo->ndo_tflag == 3)
ND_PRINT(" ");
if (ndo->ndo_tflag == 3)
break;
case 4: /* Date + Default */
break;
case 4: /* Date + Default */
- ts_date_hmsfrac_print(ndo, tvp->tv_sec, tvp->tv_usec,
- WITH_DATE, LOCAL_TIME);
+ ts_date_hmsfrac_print(ndo, tvp, WITH_DATE, LOCAL_TIME);