Addressing most of the remaining build warnings from issue thread #1617.
<details> <summary>I used master branch @ 4721e077b4ac9a9ab80db3fd9a05d6dda207f5c1 with command:</summary>
cmake -B build \
-DCMAKE_C_COMPILER=clang \
-DSECP256K1_ENABLE_MODULE_ECDH=ON \
-DSECP256K1_ENABLE_MODULE_RECOVERY=ON \
-DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON \
-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON \
-DSECP256K1_ENABLE_MODULE_MUSIG=ON \
-DSECP256K1_ENABLE_MODULE_ELLSWIFT=ON \
-DSECP256K1_BUILD_TESTS=OFF \
-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF \
-DSECP256K1_BUILD_CTIME_TESTS=OFF \
-DSECP256K1_BUILD_BENCHMARK=OFF \
-DSECP256K1_BUILD_EXAMPLES=OFF \
-DCMAKE_C_FLAGS="-Wall -Wextra -Wshorten-64-to-32 -Werror=shorten-64-to-32"
cmake --build build --verbose
</details>
<details> <summary>which produced these 14 errors:</summary>
/Users/csjones/Developer/secp256k1/src/modinv64_impl.h:279:39: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
279 | w = (f * g * (f * f - 2)) & m;
| ~ ~~~~~~~~~~~~~~~~~~~~~~^~~
/Users/csjones/Developer/secp256k1/src/modinv64_impl.h:289:19: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
289 | w = f + (((f + 1) & 4) << 1);
| ~ ~~^~~~~~~~~~~~~~~~~~~~~~
/Users/csjones/Developer/secp256k1/src/modinv64_impl.h:290:26: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
290 | w = (-w * g) & m;
| ~ ~~~~~~~~~^~~
/Users/csjones/Developer/secp256k1/src/modinv64_impl.h:370:39: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
370 | w = (f * g * (f * f - 2)) & m;
| ~ ~~~~~~~~~~~~~~~~~~~~~~^~~
/Users/csjones/Developer/secp256k1/src/modinv64_impl.h:380:19: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
380 | w = f + (((f + 1) & 4) << 1);
| ~ ~~^~~~~~~~~~~~~~~~~~~~~~
/Users/csjones/Developer/secp256k1/src/modinv64_impl.h:381:26: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
381 | w = (-w * g) & m;
| ~ ~~~~~~~~~^~~
In file included from /Users/csjones/Developer/secp256k1/src/secp256k1.c:28:
In file included from /Users/csjones/Developer/secp256k1/src/scalar_impl.h:20:
/Users/csjones/Developer/secp256k1/src/scalar_4x64_impl.h:112:42: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'int' [-Werror,-Wshorten-64-to-32]
112 | overflow = secp256k1_u128_to_u64(&t) + secp256k1_scalar_check_overflow(r);
| ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/csjones/Developer/secp256k1/src/scalar_4x64_impl.h:637:10: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
637 | m6 = c0;
| ~ ^~
/Users/csjones/Developer/secp256k1/src/scalar_4x64_impl.h:657:13: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
657 | p4 = c0 + m6;
| ~ ~~~^~~~
/Users/csjones/Developer/secp256k1/src/scalar_4x64_impl.h:677:34: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Werror,-Wshorten-64-to-32]
677 | secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r));
| ~~~~~~~~~~~~~~~~~~~~~~~ ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/csjones/Developer/secp256k1/src/secp256k1.c:30:
/Users/csjones/Developer/secp256k1/src/ecmult_impl.h:536:21: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
536 | for (i = n_wnaf - 1; i >= 0; i--) {
| ~ ~~~~~~~^~~
/Users/csjones/Developer/secp256k1/src/ecmult_impl.h:580:52: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
580 | for(j = ECMULT_TABLE_SIZE(bucket_window+2) - 1; j > 0; j--) {
| ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /Users/csjones/Developer/secp256k1/src/secp256k1.c:32:
In file included from /Users/csjones/Developer/secp256k1/src/ecmult_gen_impl.h:14:
/Users/csjones/Developer/secp256k1/src/hash_impl.h:151:52: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
151 | secp256k1_write_be32(&sizedesc[0], hash->bytes >> 29);
| ~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~^~~~~
/Users/csjones/Developer/secp256k1/src/hash_impl.h:152:52: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
152 | secp256k1_write_be32(&sizedesc[4], hash->bytes << 3);
| ~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~^~~~
14 errors generated.
</details>
I applied most of the suggested fixes from #1617 (comment) and used an explicit cast of (uint32_t) in scalar_4x64_impl.h for the two warnings not mentioned in the original issue thread. The warnings in ecmult_impl.h were skipped.
<details> <summary>Only two warnings remain after applying the changes from this PR.</summary>
/Users/csjones/Developer/secp256k1/src/ecmult_impl.h:536:21: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
536 | for (i = n_wnaf - 1; i >= 0; i--) {
| ~ ~~~~~~~^~~
/Users/csjones/Developer/secp256k1/src/ecmult_impl.h:580:52: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
580 | for(j = ECMULT_TABLE_SIZE(bucket_window+2) - 1; j > 0; j--) {
| ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
2 errors generated.
</details>
EDIT: Investigating failing CI Fixed.