[PATCH v2 1/3] Bring in linux/limits.h

Tom Rini trini at konsulko.com
Fri Apr 18 15:39:43 CEST 2025


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

> From: Simon Glass <simon.glass at 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.glass at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250418/a6b58b31/attachment.sig>


More information about the U-Boot mailing list