Opened 3 years ago

Closed 3 years ago

#18095 closed defect (fixed)

Unit test integer precision warnings on 32 bit clang targets

Reported by: teor Owned by:
Priority: Medium Milestone: Tor: 0.2.8.x-final
Component: Core Tor/Tor Version:
Severity: Minor Keywords: easy
Cc: Actual Points:
Parent ID: #17076 Points:
Reviewer: Sponsor:

Description

I think #17076 introduced some integer precision warnings on 32 bit clang targets.

https://jenkins.torproject.org/job/tor-ci-linux-master-clang/997/ARCHITECTURE=i386,SUITE=sid/console

01:08:40 src/test/test_options.c:2311:25: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'long' [-Werror,-Wshorten-64-to-32]
01:08:40   tt_int_op(tdata->opt->RelayBandwidthBurst, OP_EQ, 1000);
01:08:40   ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
01:08:40 ./src/ext/tinytest_macros.h:158:22: note: expanded from macro 'tt_int_op'
01:08:40         tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_), \
01:08:40                             ^
01:08:40 ./src/ext/tinytest_macros.h:144:26: note: expanded from macro 'tt_assert_test_type'
01:08:40         tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt,        \
01:08:40                                 ^
01:08:40 ./src/ext/tinytest_macros.h:116:16: note: expanded from macro 'tt_assert_test_fmt_type'
01:08:40         type val1_ = (a);                                               \
01:08:40                       ^
01:08:40 src/test/test_options.c:2319:25: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'long' [-Werror,-Wshorten-64-to-32]
01:08:40   tt_int_op(tdata->opt->RelayBandwidthRate, OP_EQ, 1001);
01:08:40   ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
01:08:40 ./src/ext/tinytest_macros.h:158:22: note: expanded from macro 'tt_int_op'
01:08:40         tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_), \
01:08:40                             ^
01:08:40 ./src/ext/tinytest_macros.h:144:26: note: expanded from macro 'tt_assert_test_type'
01:08:40         tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt,        \
01:08:40                                 ^
01:08:40 ./src/ext/tinytest_macros.h:116:16: note: expanded from macro 'tt_assert_test_fmt_type'
01:08:40         type val1_ = (a);                                               \
01:08:40                       ^
01:08:40 src/test/test_options.c:2350:25: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'long' [-Werror,-Wshorten-64-to-32]
01:08:40   tt_int_op(tdata->opt->BandwidthRate, OP_EQ, 1001);
01:08:40   ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
01:08:40 ./src/ext/tinytest_macros.h:158:22: note: expanded from macro 'tt_int_op'
01:08:40         tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_), \
01:08:40                             ^
01:08:40 ./src/ext/tinytest_macros.h:144:26: note: expanded from macro 'tt_assert_test_type'
01:08:40         tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt,        \
01:08:40                                 ^
01:08:40 ./src/ext/tinytest_macros.h:116:16: note: expanded from macro 'tt_assert_test_fmt_type'
01:08:40         type val1_ = (a);                                               \
01:08:40                       ^
01:08:40 src/test/test_options.c:2362:25: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'long' [-Werror,-Wshorten-64-to-32]
01:08:40   tt_int_op(tdata->opt->BandwidthBurst, OP_EQ, 1001);
01:08:40   ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
01:08:40 ./src/ext/tinytest_macros.h:158:22: note: expanded from macro 'tt_int_op'
01:08:40         tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_), \
01:08:40                             ^
01:08:40 ./src/ext/tinytest_macros.h:144:26: note: expanded from macro 'tt_assert_test_type'
01:08:40         tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt,        \
01:08:40                                 ^
01:08:40 ./src/ext/tinytest_macros.h:116:16: note: expanded from macro 'tt_assert_test_fmt_type'
01:08:40         type val1_ = (a);                                               \
01:08:40                       ^

Child Tickets

Change History (3)

comment:1 Changed 3 years ago by nickm

Probably the right answer involves replacing tt_int_op() with tt_i64_op() or tt_u64_op() as appropriate

comment:2 Changed 3 years ago by teor

Parent ID: #17076

comment:3 Changed 3 years ago by nickm

Resolution: fixed
Status: newclosed

Merged the fix from #17076

Note: See TracTickets for help on using tickets.