]> The Tcpdump Group git mirrors - tcpdump/commit
Fix incompatible pointer types with time functions calls on Windows
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 29 Mar 2024 11:26:30 +0000 (12:26 +0100)
committerfxlb <[email protected]>
Wed, 26 Mar 2025 18:38:24 +0000 (18:38 +0000)
commitdfe7c283713108859a016ef8b6035ee4186ceeda
treef105c791c584817114110f672464390209dec5a5
parent90628d21edb20ee33095c30baf848bad332b32ef
Fix incompatible pointer types with time functions calls on Windows

On Windows in a struct timestamp, tv_sec is a long not a 64-bit time_t.

The problem shows:
listening on \Device\NPF_Loopback, link-type NULL (BSD loopback),
snapshot length 262144 bytes
    1  [localtime() or gmtime() couldn't convert the date and time].052255
       IP 10.0.0.10 > 224.0.0.251: igmp v2 report 224.0.0.251
    2  [localtime() or gmtime() couldn't convert the date and time].792000
       IP 10.0.0.10.138 > 10.0.0.255.138: NBT UDP PACKET(138)

The warnings with clang-cl were:
util-print.c(253,18): warning: incompatible pointer types passing
  'const long *' to parameter of type 'const time_t *'
      (aka 'const long long *') [-Wincompatible-pointer-types]
  253 |                 tm = localtime(&tv->tv_sec);
      |                                ^~~~~~~~~~~

util-print.c(255,15): warning: incompatible pointer types passing
  'const long *' to parameter of type 'const time_t *'
      (aka 'const long long *') [-Wincompatible-pointer-types]
  255 |                 tm = gmtime(&tv->tv_sec);
      |                             ^~~~~~~~~~~

(cherry picked from commit dab871e8be7a30e511487ef0a5d401ab5657d314)
util-print.c