All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yuan Tan <tanyuan@tinylab.org>, Zhangjin Wu <falcon@tinylab.org>
Subject: Re: [PATCH v3 05/14] tools/nolibc: stdint: use int for size_t on 32bit
Date: Sat, 5 Aug 2023 18:19:29 +0200	[thread overview]
Message-ID: <20230805161929.GA15284@1wt.eu> (raw)
In-Reply-To: <20230803-nolibc-warnings-v3-5-bcc1a096ae02@weissschuh.net>

Hi Thomas,

On Thu, Aug 03, 2023 at 09:28:49AM +0200, Thomas Weißschuh wrote:
> Otherwise both gcc and clang may generate warnings about type
> mismatches:
> 
> sysroot/mips/include/string.h:12:14: warning: mismatch in argument 1 type of built-in function 'malloc'; expected 'unsigned int' [-Wbuiltin-declaration-mismatch]
>    12 | static void *malloc(size_t len);
>       |              ^~~~~~
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  tools/include/nolibc/stdint.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h
> index 4b282435a59a..0f390c3028d8 100644
> --- a/tools/include/nolibc/stdint.h
> +++ b/tools/include/nolibc/stdint.h
> @@ -15,7 +15,11 @@ typedef unsigned int       uint32_t;
>  typedef   signed int        int32_t;
>  typedef unsigned long long uint64_t;
>  typedef   signed long long  int64_t;
> +#if __SIZE_WIDTH__ == 64
>  typedef unsigned long        size_t;
> +#else
> +typedef unsigned int         size_t;
> +#endif

This one breaks gcc < 7 for me because __SIZE_WIDTH__ is not defined
there. However I could trace __SIZE_TYPE__ to be defined since at least
gcc-3.4 so instead we can do this, which will always match the type set
by the compiler (either "unsigned int" or "unsigned long int") :

  #ifdef __SIZE_TYPE__
  typedef __SIZE_TYPE__ size_t;
  #else
  typedef unsigned long size_t;
  #endif

Please just let me know if you want me to modify your patch accordingly.
I'm still continuing the tests.

Thanks,
Willy

  reply	other threads:[~2023-08-05 16:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03  7:28 [PATCH v3 00/14] tools/nolibc: enable compiler warnings Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 01/14] tools/nolibc: drop unused variables Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 02/14] tools/nolibc: fix return type of getpagesize() Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 03/14] tools/nolibc: setvbuf: avoid unused parameter warnings Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 04/14] tools/nolibc: sys: avoid implicit sign cast Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 05/14] tools/nolibc: stdint: use int for size_t on 32bit Thomas Weißschuh
2023-08-05 16:19   ` Willy Tarreau [this message]
2023-08-05 16:25     ` Thomas Weißschuh
2023-08-05 16:35       ` Willy Tarreau
2023-08-03  7:28 ` [PATCH v3 06/14] selftests/nolibc: drop unused variables Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 07/14] selftests/nolibc: mark test helpers as potentially unused Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 08/14] selftests/nolibc: make functions static if possible Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 09/14] selftests/nolibc: avoid unused parameter warnings Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 10/14] selftests/nolibc: avoid sign-compare warnings Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 11/14] selftests/nolibc: use correct return type for read() and write() Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 12/14] selftests/nolibc: prevent out of bounds access in expect_vfprintf Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 13/14] selftests/nolibc: don't strip nolibc-test Thomas Weißschuh
2023-08-03  7:28 ` [PATCH v3 14/14] selftests/nolibc: enable compiler warnings Thomas Weißschuh
2023-08-05 16:23   ` Willy Tarreau
2023-08-05 16:32     ` Willy Tarreau
2023-08-05 16:54 ` [PATCH v3 00/14] tools/nolibc: " 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=20230805161929.GA15284@1wt.eu \
    --to=w@1wt.eu \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=shuah@kernel.org \
    --cc=tanyuan@tinylab.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.