[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#861026: [x32] struct timespec tv_nsec has wrong type



Package: libc6-dev
Version: 2.24-10

Hello,

I'm investigating cockpit's build failure on x32 [1]. It builds with
-Werror=format=2 to detect format string type errors, and compiling

|                     struct stat *buf)
| [...]
|     return g_strdup_printf ("1:%lu-%ld.%ld",
|                             (unsigned long)buf->st_ino,
|                             buf->st_mtim.tv_sec,
|                             buf->st_mtim.tv_nsec);


fails like this:

> src/bridge/cockpitfsread.c: In function 'file_tag_from_stat':
> src/bridge/cockpitfsread.c:120:38: error: format '%ld' expects argument of type 'long int', but argument 3 has type '__time_t {aka long long int}' [-Werror=format=]
>      return g_strdup_printf ("1:%lu-%ld.%ld",

This is a bug in the above cockpit source which I'll fix.

> src/bridge/cockpitfsread.c:120:42: error: format '%ld' expects argument of type 'long int', but argument 4 has type '__syscall_slong_t {aka long long int}' [-Werror=format=]
>      return g_strdup_printf ("1:%lu-%ld.%ld",
>                                           ^
> cc1: some warnings being treated as errors

However, this is not. The documentation [2] defines struct timeval's "tv_nsec"
field as "long int", so %ld is correct. But glibc seems to really define it
as "__syscall_slong_t tv_nsec", and on x32 __syscall_slong_t appears to be
"long long int".

Thanks,

Martin

[1] https://buildd.debian.org/status/fetch.php?pkg=cockpit&arch=x32&ver=138-1&stamp=1491831935&raw=0
[2] https://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html


Reply to: