From: Cyril Hrubis <chrubis@suse.cz>
To: linux-api@vger.kernel.org
Cc: ltp@lists.linux.it, libc-alpha@sourceware.org
Subject: asm-generic/int-ll64.h wrongly used on x86_64?
Date: Fri, 19 Nov 2021 13:38:06 +0100 [thread overview]
Message-ID: <YZearmiVEw9/eor9@yuki> (raw)
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'}
Digging into the issue I've found that include/asm-generic/types.h looks like:
#ifndef _ASM_GENERIC_TYPES_H
#define _ASM_GENERIC_TYPES_H
/*
* int-ll64 is used everywhere now.
*/
#include <asm-generic/int-ll64.h>
#endif /* _ASM_GENERIC_TYPES_H */
Which is the cause why you cannot print __u64 with PRIu64 and would
force every userspace code to explicitly cast any __u64 in order to get
rid warnings. I would say that it would be better to fix the headers so
that __u64 has the same type as uint64_t so that PRIu64 could be then
used to print __u64 as well.
--
Cyril Hrubis
chrubis@suse.cz
next reply other threads:[~2021-11-19 12:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 12:38 Cyril Hrubis [this message]
2021-11-19 13:11 ` Florian Weimer
2021-11-19 13:53 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YZearmiVEw9/eor9@yuki \
--to=chrubis@suse.cz \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).