On Fri, Apr 18, 2025 at 04:59:13AM -0600, Simon Glass wrote:

> From: Simon Glass <simon.gl...@canonical.com>
> 
> Add part of this file from Linux v6.14 so we can include it from the
> linux/overflow.h file. Drop the relevant section from kernel.h
> 
> The top of the file is omitted since it defines things used in mbedos
> and we get an error on SIZE_MAX.
> 
> Signed-off-by: Simon Glass <simon.gl...@canonical.com>
> ---
> Error is:
> 
>   In file included from include/limits.h:6,
>                  from lib/mbedtls/external/mbedtls/library/constant_time.c:14:
>   include/linux/limits.h:7:35: error: missing binary operator before token "0"
>     7 | #define SIZE_MAX        (~(size_t)0)
>       |                                   ^
>   lib/mbedtls/external/mbedtls/library/constant_time_internal.h:65:6: note: 
> in expansion of macro ‘SIZE_MAX’
>    65 | #if (SIZE_MAX > 0xffffffffffffffffULL)
>       |      ^~~~~~~~
>   include/linux/limits.h:7:35: error: missing binary operator before token "0"
>     7 | #define SIZE_MAX        (~(size_t)0)
>       |                                   ^
>   lib/mbedtls/external/mbedtls/library/constant_time_internal.h:71:8: note: 
> in expansion of macro ‘SIZE_MAX’
>    71 | #elif (SIZE_MAX > 0xffffffff) || defined(MBEDTLS_HAVE_INT64)
>       |        ^~~~~~~~
>   make[3]: *** [scripts/Makefile.build:256: 
> lib/mbedtls/external/mbedtls/library/constant_time.o] Error 1
>   make[2]: *** [scripts/Makefile.build:398: lib/mbedtls] Error 2
> 
> Changes in v2:
> - Add new patch to bring in linux/limits.h
> 
>  include/limits.h       |  2 ++
>  include/linux/kernel.h | 12 ------------
>  include/linux/limits.h | 21 +++++++++++++++++++++
>  3 files changed, 23 insertions(+), 12 deletions(-)
>  create mode 100644 include/linux/limits.h

Ugh. I think we need to:
- Fix lib/string.c (and Fixes commit 7c7361b98d6e ("lib: implement
  strnstr()")) to not bring in <limits.h> as that should be limited to
  mbedtls usage.
- Not bring <linux/limits.h> to <limits.h> to start with at least (we
  can worry about handling wrappers around overflow protection there
  separately).

-- 
Tom

Attachment: signature.asc
Description: PGP signature

Reply via email to