Skip to content

Commit

Permalink
timing.c
Browse files Browse the repository at this point in the history
Make sure the ctx variable in function mbedtls_timing_self_test is initialized properly, to avoid build
failures with -O3 e.g. on ppc64el

cd /<<PKGBUILDDIR>>/obj-powerpc64le-linux-gnu/library && /usr/bin/cc  -I/<<PKGBUILDDIR>>/include -I/<<PKGBUILDDIR>>/library -g -O3 -Werror=implicit-function-declaration -Werror=array-bounds -Werror=clobbered -Werror=volatile-register-var -D__DEB_CANARY_CFLAGS_428fca9bc1921c25c5121f9da7815cde__ -fno-omit-frame-pointer -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/mbedtls-2.28.6-1 -D__DEB_CANARY_CPPFLAGS_428fca9bc1921c25c5121f9da7815cde__ -Wdate-time -D_FORTIFY_SOURCE=3 -Wall -Wextra -Wwrite-strings -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -Wmissing-declarations -Wmissing-prototypes -MD -MT library/CMakeFiles/mbedcrypto_static.dir/xtea.c.o -MF CMakeFiles/mbedcrypto_static.dir/xtea.c.o.d -o CMakeFiles/mbedcrypto_static.dir/xtea.c.o -c /<<PKGBUILDDIR>>/library/xtea.c
In function ‘mbedtls_timing_get_delay’,
    inlined from ‘mbedtls_timing_self_test’ at /<<PKGBUILDDIR>>/library/timing.c:427:13:
/<<PKGBUILDDIR>>/library/timing.c:334:12: error: ‘ctx.fin_ms’ may be used uninitialized [-Werror=maybe-uninitialized]
  334 |     if (ctx->fin_ms == 0) {
      |         ~~~^~~~~~~~
/<<PKGBUILDDIR>>/library/timing.c: In function ‘mbedtls_timing_self_test’:
/<<PKGBUILDDIR>>/library/timing.c:402:34: note: ‘ctx’ declared here
  402 |     mbedtls_timing_delay_context ctx;
      |                                  ^~~
In function ‘mbedtls_timing_get_delay’,
    inlined from ‘mbedtls_timing_self_test’ at /<<PKGBUILDDIR>>/library/timing.c:427:13:
/<<PKGBUILDDIR>>/library/timing.c:344:26: error: ‘ctx.int_ms’ may be used uninitialized [-Werror=maybe-uninitialized]
  344 |     if (elapsed_ms >= ctx->int_ms) {
      |                       ~~~^~~~~~~~
/<<PKGBUILDDIR>>/library/timing.c: In function ‘mbedtls_timing_self_test’:
/<<PKGBUILDDIR>>/library/timing.c:402:34: note: ‘ctx’ declared here
  402 |     mbedtls_timing_delay_context ctx;
      |                                  ^~~

Signed-off-by: Gianfranco Costamagna <[email protected]>
Signed-off-by: Gianfranco Costamagna <[email protected]>
  • Loading branch information
LocutusOfBorg committed Dec 27, 2023
1 parent 0071830 commit ca902db
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ int mbedtls_timing_self_test(int verbose)
int hardfail = 0;
struct mbedtls_timing_hr_time hires;
uint32_t a = 0, b = 0;
mbedtls_timing_delay_context ctx;
mbedtls_timing_delay_context ctx = {};

if (verbose != 0) {
mbedtls_printf(" TIMING tests note: will take some time!\n");
Expand Down

0 comments on commit ca902db

Please sign in to comment.