diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-01-03 13:21:32 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-07 13:57:55 -0800 |
commit | f1e1a328e9a26eb956d8a2fb015d810bd04d4f96 (patch) | |
tree | f977b70255ef1394f2dd72b4222fad36635fa39a /host/lib/usrp | |
parent | 40bb17709182f7ce4b3761eb7e809c2be05663d2 (diff) | |
download | uhd-f1e1a328e9a26eb956d8a2fb015d810bd04d4f96.tar.gz uhd-f1e1a328e9a26eb956d8a2fb015d810bd04d4f96.tar.bz2 uhd-f1e1a328e9a26eb956d8a2fb015d810bd04d4f96.zip |
x300: Fix compiler warnings related to type conversions
These compiler warnings mostly pop up on MSVC. Most of them are due to
inconsistent usage of size_t, uint{8,16,32}_t, and even int.
This commit changes types mostly such that variables have the correct
type to begin with, although it also contains a few explicit type-casts.
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/x300/x300_clock_ctrl.cpp | 20 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_dac_ctrl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_image_loader.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_mb_eeprom.cpp | 4 |
4 files changed, 15 insertions, 15 deletions
diff --git a/host/lib/usrp/x300/x300_clock_ctrl.cpp b/host/lib/usrp/x300/x300_clock_ctrl.cpp index f5d49c97d..93e02ca7d 100644 --- a/host/lib/usrp/x300/x300_clock_ctrl.cpp +++ b/host/lib/usrp/x300/x300_clock_ctrl.cpp @@ -68,7 +68,7 @@ public: const double dboard_clock_rate, const double system_ref_rate): _spiface(spiface), - _slaveno(slaveno), + _slaveno(static_cast<int>(slaveno)), _hw_rev(hw_rev), _master_clock_rate(master_clock_rate), _dboard_clock_rate(dboard_clock_rate), @@ -81,10 +81,10 @@ public: _lmk04816_regs.RESET = lmk04816_regs_t::RESET_RESET; this->write_regs(0); _lmk04816_regs.RESET = lmk04816_regs_t::RESET_NO_RESET; - for (size_t i = 0; i <= 16; ++i) { + for (uint8_t i = 0; i <= 16; ++i) { this->write_regs(i); } - for (size_t i = 24; i <= 31; ++i) { + for (uint8_t i = 24; i <= 31; ++i) { this->write_regs(i); } sync_clocks(); @@ -423,8 +423,8 @@ private: // VCXO runs at 96MHz, assume PLL2 reference doubler is enabled const double ref = VCXO_FREQ * 2; - const int lowest_vcodiv = std::ceil(MIN_VCO_FREQ / output_freq); - const int highest_vcodiv = std::floor(MAX_VCO_FREQ / output_freq); + const int lowest_vcodiv = static_cast<int>(std::ceil(MIN_VCO_FREQ / output_freq)); + const int highest_vcodiv = static_cast<int>(std::floor(MAX_VCO_FREQ / output_freq)); // Find the PLL2 configuration with the lowest frequency error, favoring // higher phase comparison frequencies. @@ -445,8 +445,8 @@ private: // the N predivider to odd values as well, and we may be able to get // better spur performance by balancing the predivider and the // divider. - const int n = - boost::math::round((r * try_vco_freq) / (VCXO_PLL2_N * ref)); + const int n = static_cast<int>( + boost::math::round((r * try_vco_freq) / (VCXO_PLL2_N * ref))); const double actual_mcr = (ref * VCXO_PLL2_N * n) / (vcodiv * r); const double error = std::abs(actual_mcr - output_freq); @@ -869,10 +869,10 @@ private: set_clock_delay(X300_CLOCK_WHICH_DAC0, _delays.dac_dly_ns, false); //Sets both Ch0 and Ch1 /* Write the configuration values into the LMK */ - for (size_t i = 1; i <= 16; ++i) { + for (uint8_t i = 1; i <= 16; ++i) { this->write_regs(i); } - for (size_t i = 24; i <= 31; ++i) { + for (uint8_t i = 24; i <= 31; ++i) { this->write_regs(i); } @@ -880,7 +880,7 @@ private: } const spi_iface::sptr _spiface; - const size_t _slaveno; + const int _slaveno; const size_t _hw_rev; // This is technically constant, but it can be coerced during initialization double _master_clock_rate; diff --git a/host/lib/usrp/x300/x300_dac_ctrl.cpp b/host/lib/usrp/x300/x300_dac_ctrl.cpp index d7b3892fd..a9df96002 100644 --- a/host/lib/usrp/x300/x300_dac_ctrl.cpp +++ b/host/lib/usrp/x300/x300_dac_ctrl.cpp @@ -36,7 +36,7 @@ class x300_dac_ctrl_impl : public x300_dac_ctrl { public: x300_dac_ctrl_impl(uhd::spi_iface::sptr iface, const size_t slaveno, const double refclk): - _iface(iface), _slaveno(slaveno), _refclk(refclk) + _iface(iface), _slaveno(static_cast<int>(slaveno)), _refclk(refclk) { //Power up all DAC subsystems write_ad9146_reg(0x01, 0x10); //Up: I DAC, Q DAC, Receiver, Voltage Ref, Clocks @@ -287,7 +287,7 @@ public: private: uhd::spi_iface::sptr _iface; - const size_t _slaveno; + const int _slaveno; const double _refclk; }; diff --git a/host/lib/usrp/x300/x300_image_loader.cpp b/host/lib/usrp/x300/x300_image_loader.cpp index c0d692ae5..4e2c9e580 100644 --- a/host/lib/usrp/x300/x300_image_loader.cpp +++ b/host/lib/usrp/x300/x300_image_loader.cpp @@ -89,7 +89,7 @@ typedef struct { std::string rpc_port; udp_simple::sptr write_xport; udp_simple::sptr read_xport; - uint32_t size; + size_t size; uint8_t data_in[udp_simple::mtu]; std::vector<char> bitstream; // .bin image extracted from .lvbitx file } x300_session_t; diff --git a/host/lib/usrp/x300/x300_mb_eeprom.cpp b/host/lib/usrp/x300/x300_mb_eeprom.cpp index 26f7f7913..b3ebf6101 100644 --- a/host/lib/usrp/x300/x300_mb_eeprom.cpp +++ b/host/lib/usrp/x300/x300_mb_eeprom.cpp @@ -95,7 +95,7 @@ mboard_eeprom_t x300_impl::get_mb_eeprom(uhd::i2c_iface::sptr iface) mb_eeprom["gateway"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string(); for (size_t i = 0; i < 4; i++) { - const std::string n(1, i+'0'); + const std::string n(1, char(i)+'0'); byte_copy( byte_vector_t( bytes.begin() + (offsetof(x300_eeprom_map, ip_addr)+(i*4)), @@ -194,7 +194,7 @@ void x300_impl::set_mb_eeprom( } for (size_t i = 0; i < 4; i++) { - const std::string n(1, i+'0'); + const std::string n(1, char(i)+'0'); if (mb_eeprom.has_key("ip-addr"+n)){ byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"+n]).to_bytes(), ip_addr_bytes); iface->write_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, ip_addr)+(i*4), ip_addr_bytes); |