libpcp / pcp

PCP client library
BSD 2-Clause "Simplified" License
69 stars 30 forks source link

libpcp: pcp_api: fix 64-bit time_t format #25

Open ynezz opened 1 year ago

ynezz commented 1 year ago

On newer systems time_t becomes 64-bit to allow handling of dates beyond Y2038, which yields to following compiler warning/error:

 src/pcp_api.c: In function 'pcp_wait':
 src/pcp_api.c:264:17: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'time_t' {aka 'long long int'} [-Werror=format=]
   264 |                 "Executing select with fdmax=%d, timeout = %ld s; %ld us",
       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   265 |                 fdmax, tout_select.tv_sec, (long int)tout_select.tv_usec);
       |                        ~~~~~~~~~~~~~~~~~~
       |                                   |
       |                                   time_t {aka long long int}

So lets fix it by casting the older 32-bit time_t to 64-bit and use %lld format tag.

Signed-off-by: Petr Štetiar ynezz@true.cz