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

Simon Glass sjg at chromium.org
Wed May 7 10:47:13 CEST 2025


Hi Tom,

On Fri, 18 Apr 2025 at 15:39, Tom Rini <trini at konsulko.com> wrote:
>
> 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).

There are quite a few places which need the limits. If I remove the
dups from kernel.h then some things don't compile, at least not
without including linux/limits,h in limits,h (which it seems to me we
should do).

So is this something you would like to take over, or do we need Linaro
do fix up mbedtls, or...?

Regards,
Simon


More information about the U-Boot mailing list