Add missing includes of limits.h #717

Merged
bensze01 merged 1 commit from limits into development 2026-03-17 11:18:19 -05:00
bensze01 commented 2026-03-17 05:45:29 -05:00 (Migrated from github.com)

Description

Since 1023eafc10, we are using macros defined in limits.h without including it, causing them to default to 0.

See: #682

[9/458] Building C object drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o
FAILED: drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o 
/usr/bin/cc  -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/build/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/core -I/home/bensze01/programming/mbedtls/tf-psa-crypto/dispatch -I/home/bensze01/programming/mbedtls/tf-psa-crypto/extras -I/home/bensze01/programming/mbedtls/tf-psa-crypto/platform -I/home/bensze01/programming/mbedtls/tf-psa-crypto/utilities -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/everest/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/p256-m -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/pqcp/include -std=c99 -Wall -Wextra -Wwrite-strings -Wmissing-prototypes -Wundef -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -Wmissing-declarations -MD -MT drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o -MF drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o.d -o drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o -c /home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c
/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c: In function ‘mbedtls_mpi_core_clz’:
/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c:29:30: error: "UINT_MAX" is not defined, evaluates to 0 [-Werror=undef]
   29 | #if (MBEDTLS_MPI_UINT_MAX == UINT_MAX) && __has_builtin(__builtin_clz)
      |                              ^~~~~~~~
/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c:31:32: error: "ULONG_MAX" is not defined, evaluates to 0 [-Werror=undef]
   31 | #elif (MBEDTLS_MPI_UINT_MAX == ULONG_MAX) && __has_builtin(__builtin_clzl)
      |                                ^~~~~~~~~
/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c:33:32: error: "ULLONG_MAX" is not defined, evaluates to 0 [-Werror=undef]
   33 | #elif (MBEDTLS_MPI_UINT_MAX == ULLONG_MAX) && __has_builtin(__builtin_clzll)
      |                                ^~~~~~~~~~
cc1: all warnings being treated as errors
[47/458] Building C object utilities/CMakeFiles/utilities.dir/pkcs5.c.o
FAILED: utilities/CMakeFiles/utilities.dir/pkcs5.c.o 
/usr/bin/cc  -I/home/bensze01/programming/mbedtls/tf-psa-crypto/build/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/core -I/home/bensze01/programming/mbedtls/tf-psa-crypto/dispatch -I/home/bensze01/programming/mbedtls/tf-psa-crypto/extras -I/home/bensze01/programming/mbedtls/tf-psa-crypto/platform -I/home/bensze01/programming/mbedtls/tf-psa-crypto/utilities -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/pqcp/src -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/everest/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/pqcp/include -std=c99 -Wall -Wextra -Wwrite-strings -Wmissing-prototypes -Wundef -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -Wmissing-declarations -MD -MT utilities/CMakeFiles/utilities.dir/pkcs5.c.o -MF utilities/CMakeFiles/utilities.dir/pkcs5.c.o.d -o utilities/CMakeFiles/utilities.dir/pkcs5.c.o -c /home/bensze01/programming/mbedtls/tf-psa-crypto/utilities/pkcs5.c
/home/bensze01/programming/mbedtls/tf-psa-crypto/utilities/pkcs5.c: In function ‘pkcs5_pbkdf2_hmac’:
/home/bensze01/programming/mbedtls/tf-psa-crypto/utilities/pkcs5.c:269:5: error: "UINT_MAX" is not defined, evaluates to 0 [-Werror=undef]
  269 | #if UINT_MAX > 0xFFFFFFFF
      |     ^~~~~~~~
cc1: all warnings being treated as errors
[65/458] Building C object programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o
FAILED: programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o 
/usr/bin/cc  -I/home/bensze01/programming/mbedtls/tf-psa-crypto/framework/tests/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/build/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/everest/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/pqcp/include -std=c99 -Wall -Wextra -Wwrite-strings -Wmissing-prototypes -Wundef -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -MD -MT programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o -MF programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o.d -o programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o -c /home/bensze01/programming/mbedtls/tf-psa-crypto/programs/psa/key_ladder_demo.c
/home/bensze01/programming/mbedtls/tf-psa-crypto/programs/psa/key_ladder_demo.c: In function ‘wrap_data’:
/home/bensze01/programming/mbedtls/tf-psa-crypto/programs/psa/key_ladder_demo.c:368:5: error: "LONG_MAX" is not defined, evaluates to 0 [-Werror=undef]
  368 | #if LONG_MAX > SIZE_MAX
      |     ^~~~~~~~
cc1: all warnings being treated as errors
[79/458] Generating suites/test_suite_psa_crypto_generate_key.generated.data, suites/test_suite_psa_crypto_low_hash.....data, suites/test_suite_psa_crypto_storage_format.current.data, suites/test_suite_psa_crypto_storage_format.v0.data
ninja: build stopped: cannot make progress due to previous errors.

The three code segments affected:
github.com/Mbed-TLS/TF-PSA-Crypto@e5fdb3fe2c/drivers/builtin/src/bignum_core.c (L28-L52)
github.com/Mbed-TLS/TF-PSA-Crypto@e5fdb3fe2c/utilities/pkcs5.c (L269-L273)
github.com/Mbed-TLS/TF-PSA-Crypto@e5fdb3fe2c/programs/psa/key_ladder_demo.c (L368-L374)

PR checklist

  • changelog not required because: The bug was introduced after v1.0.0, in 1023eafc10
  • framework PR not required
  • mbedtls development PR not required because: The submodule pointer will be updated as part of the release process.
  • mbedtls 3.6 PR not required because: the bug doesn't affect mbedtls 3.6
  • tests Non-regression test are coming in a separate PR.
## Description Since 1023eafc100a84299dc258bee117607a99963d5d, we are using macros defined in `limits.h` without including it, causing them to default to `0`. See: #682 ```shell [9/458] Building C object drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o FAILED: drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o /usr/bin/cc -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/build/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/core -I/home/bensze01/programming/mbedtls/tf-psa-crypto/dispatch -I/home/bensze01/programming/mbedtls/tf-psa-crypto/extras -I/home/bensze01/programming/mbedtls/tf-psa-crypto/platform -I/home/bensze01/programming/mbedtls/tf-psa-crypto/utilities -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/everest/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/p256-m -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/pqcp/include -std=c99 -Wall -Wextra -Wwrite-strings -Wmissing-prototypes -Wundef -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -Wmissing-declarations -MD -MT drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o -MF drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o.d -o drivers/builtin/CMakeFiles/builtin.dir/src/bignum_core.c.o -c /home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c /home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c: In function ‘mbedtls_mpi_core_clz’: /home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c:29:30: error: "UINT_MAX" is not defined, evaluates to 0 [-Werror=undef] 29 | #if (MBEDTLS_MPI_UINT_MAX == UINT_MAX) && __has_builtin(__builtin_clz) | ^~~~~~~~ /home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c:31:32: error: "ULONG_MAX" is not defined, evaluates to 0 [-Werror=undef] 31 | #elif (MBEDTLS_MPI_UINT_MAX == ULONG_MAX) && __has_builtin(__builtin_clzl) | ^~~~~~~~~ /home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c:33:32: error: "ULLONG_MAX" is not defined, evaluates to 0 [-Werror=undef] 33 | #elif (MBEDTLS_MPI_UINT_MAX == ULLONG_MAX) && __has_builtin(__builtin_clzll) | ^~~~~~~~~~ cc1: all warnings being treated as errors [47/458] Building C object utilities/CMakeFiles/utilities.dir/pkcs5.c.o FAILED: utilities/CMakeFiles/utilities.dir/pkcs5.c.o /usr/bin/cc -I/home/bensze01/programming/mbedtls/tf-psa-crypto/build/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/core -I/home/bensze01/programming/mbedtls/tf-psa-crypto/dispatch -I/home/bensze01/programming/mbedtls/tf-psa-crypto/extras -I/home/bensze01/programming/mbedtls/tf-psa-crypto/platform -I/home/bensze01/programming/mbedtls/tf-psa-crypto/utilities -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/src -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/pqcp/src -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/everest/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/pqcp/include -std=c99 -Wall -Wextra -Wwrite-strings -Wmissing-prototypes -Wundef -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -Wmissing-declarations -MD -MT utilities/CMakeFiles/utilities.dir/pkcs5.c.o -MF utilities/CMakeFiles/utilities.dir/pkcs5.c.o.d -o utilities/CMakeFiles/utilities.dir/pkcs5.c.o -c /home/bensze01/programming/mbedtls/tf-psa-crypto/utilities/pkcs5.c /home/bensze01/programming/mbedtls/tf-psa-crypto/utilities/pkcs5.c: In function ‘pkcs5_pbkdf2_hmac’: /home/bensze01/programming/mbedtls/tf-psa-crypto/utilities/pkcs5.c:269:5: error: "UINT_MAX" is not defined, evaluates to 0 [-Werror=undef] 269 | #if UINT_MAX > 0xFFFFFFFF | ^~~~~~~~ cc1: all warnings being treated as errors [65/458] Building C object programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o FAILED: programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o /usr/bin/cc -I/home/bensze01/programming/mbedtls/tf-psa-crypto/framework/tests/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/build/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/builtin/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/everest/include -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m -I/home/bensze01/programming/mbedtls/tf-psa-crypto/drivers/pqcp/include -std=c99 -Wall -Wextra -Wwrite-strings -Wmissing-prototypes -Wundef -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -MD -MT programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o -MF programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o.d -o programs/psa/CMakeFiles/key_ladder_demo.dir/key_ladder_demo.c.o -c /home/bensze01/programming/mbedtls/tf-psa-crypto/programs/psa/key_ladder_demo.c /home/bensze01/programming/mbedtls/tf-psa-crypto/programs/psa/key_ladder_demo.c: In function ‘wrap_data’: /home/bensze01/programming/mbedtls/tf-psa-crypto/programs/psa/key_ladder_demo.c:368:5: error: "LONG_MAX" is not defined, evaluates to 0 [-Werror=undef] 368 | #if LONG_MAX > SIZE_MAX | ^~~~~~~~ cc1: all warnings being treated as errors [79/458] Generating suites/test_suite_psa_crypto_generate_key.generated.data, suites/test_suite_psa_crypto_low_hash.....data, suites/test_suite_psa_crypto_storage_format.current.data, suites/test_suite_psa_crypto_storage_format.v0.data ninja: build stopped: cannot make progress due to previous errors. ``` The three code segments affected: https://github.com/Mbed-TLS/TF-PSA-Crypto/blob/e5fdb3fe2cc6d8842356e67546b482741ad2388c/drivers/builtin/src/bignum_core.c#L28-L52 https://github.com/Mbed-TLS/TF-PSA-Crypto/blob/e5fdb3fe2cc6d8842356e67546b482741ad2388c/utilities/pkcs5.c#L269-L273 https://github.com/Mbed-TLS/TF-PSA-Crypto/blob/e5fdb3fe2cc6d8842356e67546b482741ad2388c/programs/psa/key_ladder_demo.c#L368-L374 ## PR checklist - [x] **changelog** not required because: The bug was introduced after v1.0.0, in 1023eafc100a84299dc258bee117607a99963d5d - [x] **framework PR** not required - [x] **mbedtls development PR** not required because: The submodule pointer will be updated as part of the release process. - [x] **mbedtls 3.6 PR** not required because: the bug doesn't affect mbedtls 3.6 - **tests** Non-regression test are coming in a separate PR.
ronald-cron-arm (Migrated from github.com) approved these changes 2026-03-17 07:06:39 -05:00
ronald-cron-arm (Migrated from github.com) left a comment

LGTM

LGTM
yanesca (Migrated from github.com) approved these changes 2026-03-17 07:53:57 -05:00
yanesca (Migrated from github.com) left a comment

LGTM

LGTM
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/TF-PSA-Crypto!717
No description provided.