diff options
author | Martin Braun <martin.braun@ettus.com> | 2015-03-11 16:45:19 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-03-11 16:58:23 -0700 |
commit | cc7d37f114d5a14b4e45372f38324bf95115b6b9 (patch) | |
tree | 0b6a39418c0aa5caafa3039b578c94d3db8f1775 | |
parent | fae746179cbb1d8ac146dcae9b5d6cb58b366a56 (diff) | |
download | uhd-cc7d37f114d5a14b4e45372f38324bf95115b6b9.tar.gz uhd-cc7d37f114d5a14b4e45372f38324bf95115b6b9.tar.bz2 uhd-cc7d37f114d5a14b4e45372f38324bf95115b6b9.zip |
uhd: Fixed several type-cast related warnings for naggy compilers
-rw-r--r-- | host/examples/txrx_loopback_to_file.cpp | 4 | ||||
-rw-r--r-- | host/include/uhd/utils/fp_compare_delta.ipp | 20 | ||||
-rw-r--r-- | host/include/uhd/utils/math.hpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_3000.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/cores/time_core_3000.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_cbx.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 2 | ||||
-rw-r--r-- | host/tests/fp_compare_delta_test.cpp | 26 | ||||
-rw-r--r-- | host/tests/fp_compare_epsilon_test.cpp | 32 | ||||
-rw-r--r-- | host/utils/usrp_cal_utils.hpp | 2 |
10 files changed, 49 insertions, 49 deletions
diff --git a/host/examples/txrx_loopback_to_file.cpp b/host/examples/txrx_loopback_to_file.cpp index 4eb6daa6c..efa23c410 100644 --- a/host/examples/txrx_loopback_to_file.cpp +++ b/host/examples/txrx_loopback_to_file.cpp @@ -182,7 +182,7 @@ template<typename samp_type> void recv_to_file( UHD_ASSERT_THROW(outfiles.size() == buffs.size()); UHD_ASSERT_THROW(buffs.size() == rx_channel_nums.size()); bool overflow_message = true; - float timeout = settling_time + 0.1; //expected settling time + padding for first recv + float timeout = settling_time + 0.1f; //expected settling time + padding for first recv //setup streaming uhd::stream_cmd_t stream_cmd((num_requested_samples == 0)? @@ -196,7 +196,7 @@ template<typename samp_type> void recv_to_file( while(not stop_signal_called and (num_requested_samples != num_total_samps or num_requested_samples == 0)){ size_t num_rx_samps = rx_stream->recv(buff_ptrs, samps_per_buff, md, timeout); - timeout = 0.1; //small timeout for subsequent recv + timeout = 0.1f; //small timeout for subsequent recv if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) { std::cout << boost::format("Timeout while streaming") << std::endl; diff --git a/host/include/uhd/utils/fp_compare_delta.ipp b/host/include/uhd/utils/fp_compare_delta.ipp index 092ade6e9..49cbc281b 100644 --- a/host/include/uhd/utils/fp_compare_delta.ipp +++ b/host/include/uhd/utils/fp_compare_delta.ipp @@ -100,8 +100,8 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator==(fp_compare_delta<float_t> lhs, double rhs) { - float_t delta = fp_compare_select_delta(double(lhs._delta), - DOUBLE_PRECISION_DELTA); + float_t delta = float_t(fp_compare_select_delta(double(lhs._delta), + DOUBLE_PRECISION_DELTA)); return (std::fabs(lhs._value - rhs) < delta); } @@ -112,8 +112,8 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator<(fp_compare_delta<float_t> lhs, double rhs) { - float_t delta = fp_compare_select_delta(double(lhs._delta), - DOUBLE_PRECISION_DELTA); + float_t delta = float_t(fp_compare_select_delta(double(lhs._delta), + DOUBLE_PRECISION_DELTA)); return ((rhs - lhs._value) > delta); } @@ -124,8 +124,8 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator>(fp_compare_delta<float_t> lhs, double rhs) { - float_t delta = fp_compare_select_delta(double(lhs._delta), - DOUBLE_PRECISION_DELTA); + float_t delta = float_t(fp_compare_select_delta(double(lhs._delta), + DOUBLE_PRECISION_DELTA)); return ((lhs._value - rhs) > delta); } @@ -148,8 +148,8 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator<(double lhs, fp_compare_delta<float_t> rhs) { - float_t delta = fp_compare_select_delta(DOUBLE_PRECISION_DELTA, - double(rhs._delta)); + float_t delta = float_t(fp_compare_select_delta(DOUBLE_PRECISION_DELTA, + double(rhs._delta))); return ((rhs._value - lhs) > delta); } @@ -160,8 +160,8 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator>(double lhs, fp_compare_delta<float_t> rhs) { - float_t delta = fp_compare_select_delta(DOUBLE_PRECISION_DELTA, - double(rhs._delta)); + float_t delta = float_t(fp_compare_select_delta(DOUBLE_PRECISION_DELTA, + double(rhs._delta))); return ((lhs - rhs._value) > delta); } diff --git a/host/include/uhd/utils/math.hpp b/host/include/uhd/utils/math.hpp index e6ac4d3dc..4f88494d6 100644 --- a/host/include/uhd/utils/math.hpp +++ b/host/include/uhd/utils/math.hpp @@ -155,7 +155,7 @@ namespace fp_compare { * These are the default deltas used by the 'fp_compare_delta' class for * single and double-precision floating point comparisons. */ - static const float SINGLE_PRECISION_DELTA = 1e-3; + static const float SINGLE_PRECISION_DELTA = 1e-3f; static const double DOUBLE_PRECISION_DELTA = 1e-5; /*! Floating-point delta to use for frequency comparisons. */ diff --git a/host/lib/usrp/cores/rx_dsp_core_3000.cpp b/host/lib/usrp/cores/rx_dsp_core_3000.cpp index 13d69920a..8a131ffb4 100644 --- a/host/lib/usrp/cores/rx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_3000.cpp @@ -72,7 +72,7 @@ public: { UHD_SAFE_CALL ( - //NOP + ;//NOP ) } diff --git a/host/lib/usrp/cores/time_core_3000.cpp b/host/lib/usrp/cores/time_core_3000.cpp index aa5d5593d..ffae5dc0d 100644 --- a/host/lib/usrp/cores/time_core_3000.cpp +++ b/host/lib/usrp/cores/time_core_3000.cpp @@ -50,7 +50,7 @@ struct time_core_3000_impl : time_core_3000 { UHD_SAFE_CALL ( - //NOP + ;//NOP ) } @@ -71,8 +71,8 @@ struct time_core_3000_impl : time_core_3000 UHD_MSG(status) << ((test_fail)? " fail" : "pass") << std::endl; //useful warning for debugging actual rate - const size_t ticks_elapsed = _tick_rate*approx_secs; - const size_t appox_rate = ticks_elapsed/(sleep_millis/1e3); + const size_t ticks_elapsed = size_t(_tick_rate*approx_secs); + const size_t appox_rate = size_t(ticks_elapsed/(sleep_millis/1e3)); if (test_fail) UHD_MSG(warning) << "Expecting clock rate: " << (_tick_rate/1e6) << " MHz\n" << "Appoximate clock rate: " << (appox_rate/1e6) << " MHz\n" diff --git a/host/lib/usrp/dboard/db_cbx.cpp b/host/lib/usrp/dboard/db_cbx.cpp index db7f84932..ad255460e 100644 --- a/host/lib/usrp/dboard/db_cbx.cpp +++ b/host/lib/usrp/dboard/db_cbx.cpp @@ -142,7 +142,7 @@ double sbx_xcvr::cbx::set_lo_freq(dboard_iface::unit_t unit, double target_freq) } //keep pfd freq low enough to achieve 50kHz BS clock - BS = std::ceil(pfd_freq / 50e3); + BS = int(std::ceil(pfd_freq / 50e3)); if(BS <= 1023) break; } diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 45e736757..794438b90 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -1162,7 +1162,7 @@ public: { if (_tree->exists(mb_root(mboard) / "gpio" / bank)) { - return _tree->access<boost::uint64_t>(mb_root(mboard) / "gpio" / bank / attr).get(); + return boost::uint32_t(_tree->access<boost::uint64_t>(mb_root(mboard) / "gpio" / bank / attr).get()); } if (bank.size() > 2 and bank[1] == 'X') { diff --git a/host/tests/fp_compare_delta_test.cpp b/host/tests/fp_compare_delta_test.cpp index 9b009a79d..0ac4e257d 100644 --- a/host/tests/fp_compare_delta_test.cpp +++ b/host/tests/fp_compare_delta_test.cpp @@ -101,8 +101,8 @@ BOOST_AUTO_TEST_CASE(double_equality_operators) { BOOST_AUTO_TEST_CASE(float_inequality_operators) { // Test inequality operator, which is based on equality operator - fp_compare_delta<float> alpha = fp_compare_delta<float>(127.0); - fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 1.19e-3); + fp_compare_delta<float> alpha = fp_compare_delta<float>(127.0f); + fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 1.19e-3f); BOOST_CHECK(alpha != beta); BOOST_CHECK(alpha != float(alpha._value + 1.19e-3)); @@ -119,17 +119,17 @@ BOOST_AUTO_TEST_CASE(double_inequality_operators) { BOOST_AUTO_TEST_CASE(float_lessthan_operators) { // Test less-than operator - fp_compare_delta<float> alpha = fp_compare_delta<float>(274192.7); - fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value - 0.2); + fp_compare_delta<float> alpha = fp_compare_delta<float>(274192.7f); + fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value - 0.2f); BOOST_CHECK(beta < alpha); BOOST_CHECK(float(alpha._value - 0.2) < alpha); // Confirm false less-than case - fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value - 1.2); + fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value - 1.2f); BOOST_CHECK(not (alpha < charlie)); - BOOST_CHECK(not (alpha < float(alpha._value - 1.2))); + BOOST_CHECK(not (alpha < float(alpha._value - 1.2f))); } BOOST_AUTO_TEST_CASE(double_lessthan_operators) { @@ -149,14 +149,14 @@ BOOST_AUTO_TEST_CASE(double_lessthan_operators) { BOOST_AUTO_TEST_CASE(float_lessthanequals_operators) { // Test that <= correctly reports for equal values - fp_compare_delta<float> alpha = fp_compare_delta<float>(827.3); + fp_compare_delta<float> alpha = fp_compare_delta<float>(827.3f); fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value); BOOST_CHECK(alpha <= beta); BOOST_CHECK(alpha <= float(alpha._value)); // Test that <= correctly reports for less-than values - fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value - 1.2); + fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value - 1.2f); BOOST_CHECK(charlie <= alpha); BOOST_CHECK(float(alpha._value - 1.2) <= alpha); @@ -179,14 +179,14 @@ BOOST_AUTO_TEST_CASE(double_lessthanequals_operators) { BOOST_AUTO_TEST_CASE(float_greaterthan_operators) { // Test basic greater-than functionality - fp_compare_delta<float> alpha = fp_compare_delta<float>(98325.4); - fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 0.15); + fp_compare_delta<float> alpha = fp_compare_delta<float>(98325.4f); + fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 0.15f); BOOST_CHECK(beta > alpha); BOOST_CHECK(float(alpha._value + 0.15) > alpha); // Test false greater-than case - fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value + 1.2); + fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value + 1.2f); BOOST_CHECK(not (alpha > charlie)); BOOST_CHECK(not (alpha > float(alpha._value + 1.2))); @@ -209,14 +209,14 @@ BOOST_AUTO_TEST_CASE(double_greaterthan_operators) { BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators) { // Test that >= correctly reports for equal values - fp_compare_delta<float> alpha = fp_compare_delta<float>(7834.89); + fp_compare_delta<float> alpha = fp_compare_delta<float>(7834.89f); fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value); BOOST_CHECK(alpha >= beta); BOOST_CHECK(alpha >= float(alpha._value)); // Test that >= correctly reports for greater-than values - fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value + 4.8); + fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value + 4.8f); BOOST_CHECK(charlie >= alpha); BOOST_CHECK(float(alpha._value + 4.8) >= alpha); diff --git a/host/tests/fp_compare_epsilon_test.cpp b/host/tests/fp_compare_epsilon_test.cpp index 5790318c2..45687ad26 100644 --- a/host/tests/fp_compare_epsilon_test.cpp +++ b/host/tests/fp_compare_epsilon_test.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE(fp_compare_epsilon_constructors) { // Test constructor with specified epsilon fp_compare_epsilon<float> foxtrot = fp_compare_epsilon<float>(alpha._value, uhd::math::SINGLE_PRECISION_EPSILON); - fp_compare_epsilon<float> gamma = fp_compare_epsilon<float>(alpha._value, 2.0e-1); + fp_compare_epsilon<float> gamma = fp_compare_epsilon<float>(alpha._value, 2.0e-1f); BOOST_CHECK_EQUAL(alpha._epsilon, foxtrot._epsilon); BOOST_CHECK(not (alpha._epsilon == gamma._epsilon)); @@ -102,10 +102,10 @@ BOOST_AUTO_TEST_CASE(double_equality_operators) { BOOST_AUTO_TEST_CASE(float_inequality_operators) { // Test inequality operator, which is based on equality operator fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(127.0); - fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value + 1.19e-5); + fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value + 1.19e-5f); BOOST_CHECK(alpha != beta); - BOOST_CHECK(alpha != float(alpha._value + 1.19e-5)); + BOOST_CHECK(alpha != float(alpha._value + 1.19e-5f)); } BOOST_AUTO_TEST_CASE(double_inequality_operators) { @@ -119,17 +119,17 @@ BOOST_AUTO_TEST_CASE(double_inequality_operators) { BOOST_AUTO_TEST_CASE(float_lessthan_operators) { // Test less-than operator - fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(274192.7); - fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value - 0.15); + fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(274192.7f); + fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value - 0.15f); BOOST_CHECK(beta < alpha); BOOST_CHECK(float(alpha._value - 0.15) < alpha); // Confirm false less-than case - fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value - 1.2); + fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value - 1.2f); BOOST_CHECK(not (alpha < charlie)); - BOOST_CHECK(not (alpha < float(alpha._value - 1.2))); + BOOST_CHECK(not (alpha < float(alpha._value - 1.2f))); } BOOST_AUTO_TEST_CASE(double_lessthan_operators) { @@ -149,14 +149,14 @@ BOOST_AUTO_TEST_CASE(double_lessthan_operators) { BOOST_AUTO_TEST_CASE(float_lessthanequals_operators) { // Test that <= correctly reports for equal values - fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(827.3); + fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(827.3f); fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value); BOOST_CHECK(alpha <= beta); BOOST_CHECK(alpha <= float(alpha._value)); // Test that <= correctly reports for less-than values - fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value - 1.2); + fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value - 1.2f); BOOST_CHECK(charlie <= alpha); BOOST_CHECK(float(alpha._value - 1.2) <= alpha); @@ -179,17 +179,17 @@ BOOST_AUTO_TEST_CASE(double_lessthanequals_operators) { BOOST_AUTO_TEST_CASE(float_greaterthan_operators) { // Test basic greater-than functionality - fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(98325.4); - fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value + 0.15); + fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(98325.4f); + fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value + 0.15f); BOOST_CHECK(beta > alpha); BOOST_CHECK(float(alpha._value + 0.15) > alpha); // Test false greater-than case - fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value + 1.2); + fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value + 1.2f); BOOST_CHECK(not (alpha > charlie)); - BOOST_CHECK(not (alpha > float(alpha._value + 1.2))); + BOOST_CHECK(not (alpha > float(alpha._value + 1.2f))); } BOOST_AUTO_TEST_CASE(double_greaterthan_operators) { @@ -209,17 +209,17 @@ BOOST_AUTO_TEST_CASE(double_greaterthan_operators) { BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators) { // Test that >= correctly reports for equal values - fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(7834.89); + fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(7834.89f); fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value); BOOST_CHECK(alpha >= beta); BOOST_CHECK(alpha >= float(alpha._value)); // Test that >= correctly reports for greater-than values - fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value + 4.8); + fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value + 4.8f); BOOST_CHECK(charlie >= alpha); - BOOST_CHECK(float(alpha._value + 4.8) >= alpha); + BOOST_CHECK(float(alpha._value + 4.8f) >= alpha); } BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators) { diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp index c027a4785..ccdb0a61d 100644 --- a/host/utils/usrp_cal_utils.hpp +++ b/host/utils/usrp_cal_utils.hpp @@ -249,7 +249,7 @@ static void capture_samples( // Right after the stream is started, there will be transient data. // That transient data is discarded and only "good" samples are returned. - size_t nsamps_to_discard = usrp->get_rx_rate() * 0.001; // 1ms to be discarded + size_t nsamps_to_discard = size_t(usrp->get_rx_rate() * 0.001); // 1ms to be discarded std::vector<samp_type> discard_buff(nsamps_to_discard); uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); |