[LTP] asm-generic/int-ll64.h wrongly used on x86_64?

Florian Weimer fweimer@redhat.com
Fri Nov 19 14:11:43 CET 2021

* Cyril Hrubis:

> Hi!
> I was writing simple userspace code that prints the values from the
> struct statx the line in question looks like:
> 	printf("%" PRIu64 "\n", st.stx_size);
> This unexpectedly gives me warning on x86_64:
> warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type '__u64' {aka 'long long unsigned int'}

The correct format depends on whether you use struct statx from the
glibc headers or the Linux UAPI headers.  glibc uses uint64_t, Linux
uses __u64.  uint64_t in glibc prefers unsigned long if the type is
64-bit, Linux uses unsigned long long unconditionally.

One solution is to use %ju and cast to (uintmax_t).  Other cast-based
approaches are possible as well.

I'm not happy with the situation because those casts reduce type safety
and may suppress relevant compiler warnings.


More information about the ltp mailing list