public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: "Shuah Khan" <shuah@kernel.org>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 15/32] tools/nolibc: use intmax definitions from compiler
Date: Tue, 4 Mar 2025 08:37:42 +0100	[thread overview]
Message-ID: <20250304073742.GA9911@1wt.eu> (raw)
In-Reply-To: <20250304-nolibc-kselftest-harness-v1-15-adca7cd231e2@linutronix.de>

Hi Thomas,

On Tue, Mar 04, 2025 at 08:10:45AM +0100, Thomas Weißschuh wrote:
> The printf format checking in the compiler uses the intmax types from
> the compiler, not libc. This can lead to compiler errors.
> 
> Instead use the types already provided by the compiler.
> 
> Example issue with clang 19 for arm64:
> 
> nolibc-test.c:30:2: error: format specifies type 'uintmax_t' (aka 'unsigned
> long') but the argument has type 'uintmax_t' (aka 'unsigned long long')
> [-Werror,-Wformat]
> 
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
>  tools/include/nolibc/stdint.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h
> index cd79ddd6170e05b19945e66151bcbcf840028d32..b052ad6303c38f09685b645268dad1fa8848370d 100644
> --- a/tools/include/nolibc/stdint.h
> +++ b/tools/include/nolibc/stdint.h
> @@ -39,8 +39,8 @@ typedef   size_t      uint_fast32_t;
>  typedef  int64_t       int_fast64_t;
>  typedef uint64_t      uint_fast64_t;
>  
> -typedef  int64_t           intmax_t;
> -typedef uint64_t          uintmax_t;
> +typedef __INTMAX_TYPE__    intmax_t;
> +typedef __UINTMAX_TYPE__  uintmax_t;

Just thinking loud. While I understand the rationale behind this
change, it somewhat contradicts the one on printf where we explicitly
use it as an "unsigned long long" that's expected to be 64 bits:

   CASE_TEST(uintmax_t);    EXPECT_VFPRINTF(20, "18446744073709551615", "%ju", 0xffffffffffffffffULL); break;

Do we really have guarantees that a compiler will always declare
it as a 64-bit or unsigned long long ? E.g. we could see new
compilers decide that uintmax_t becomes 128-bit. Well, maybe in
that case it will simply be a matter of updating the test case
after all...

Willy

  reply	other threads:[~2025-03-04  7:38 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04  7:10 [PATCH 00/32] kselftest harness and nolibc compatibility Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 01/32] selftests: harness: Add harness selftest Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 02/32] selftests: harness: Use C89 comment style Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 03/32] selftests: harness: Ignore unused variant argument warning Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 04/32] selftests: harness: Mark functions without prototypes static Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 05/32] selftests: harness: Remove inline qualifier for wrappers Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 06/32] selftests: harness: Guard includes on nolibc Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 07/32] selftests: harness: Remove dependency on libatomic Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 08/32] selftests: harness: Implement test timeouts through pidfd Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 09/32] selftests: harness: Don't set setup_completed for fixtureless tests Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 10/32] selftests: harness: Always provide "self" and "variant" Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 11/32] selftests: harness: Move teardown conditional into test metadata Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 12/32] selftests: harness: Add teardown callback to " Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 13/32] selftests: harness: Stop using setjmp()/longjmp() Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 14/32] tools/nolibc: handle intmax_t/uintmax_t in printf Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 15/32] tools/nolibc: use intmax definitions from compiler Thomas Weißschuh
2025-03-04  7:37   ` Willy Tarreau [this message]
2025-03-04 11:08     ` Thomas Weißschuh
2025-03-04 20:29       ` Willy Tarreau
2025-03-04  7:10 ` [PATCH 16/32] tools/nolibc: use pselect6_time64 if available Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 17/32] tools/nolibc: use ppoll_time64 " Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 18/32] tools/nolibc: add tolower() and toupper() Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 19/32] tools/nolibc: add _exit() Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 20/32] tools/nolibc: add setpgrp() Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 21/32] tools/nolibc: implement waitpid() in terms of waitid() Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 22/32] Revert "selftests/nolibc: use waitid() over waitpid()" Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 23/32] tools/nolibc: add dprintf() and vdprintf() Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 24/32] tools/nolibc: add getopt() Thomas Weißschuh
2025-03-04  7:54   ` Willy Tarreau
2025-03-05  7:25     ` Thomas Weißschuh
2025-03-05  8:03       ` Willy Tarreau
2025-03-04  7:10 ` [PATCH 25/32] tools/nolibc: allow different write callbacks in printf Thomas Weißschuh
2025-03-04  7:59   ` Willy Tarreau
2025-03-04 11:10     ` Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 26/32] tools/nolibc: allow limiting of printf destination size Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 27/32] tools/nolibc: add snprintf() and friends Thomas Weißschuh
2025-03-04  8:01   ` Willy Tarreau
2025-03-04  7:10 ` [PATCH 28/32] selftests/nolibc: use snprintf() for printf tests Thomas Weißschuh
2025-03-04  7:10 ` [PATCH 29/32] selftests/nolibc: rename vfprintf test suite Thomas Weißschuh
2025-03-04  7:11 ` [PATCH 30/32] selftests/nolibc: add test for snprintf() truncation Thomas Weißschuh
2025-03-04  7:11 ` [PATCH 31/32] tools/nolibc: implement width padding in printf() Thomas Weißschuh
2025-03-04  7:11 ` [PATCH 32/32] HACK: selftests/nolibc: demonstrate usage of the kselftest harness Thomas Weißschuh
2025-03-04  8:06 ` [PATCH 00/32] kselftest harness and nolibc compatibility Willy Tarreau

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=20250304073742.GA9911@1wt.eu \
    --to=w@1wt.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=thomas.weissschuh@linutronix.de \
    /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