diff options
Diffstat (limited to 'host/lib/include/uhdlib')
-rw-r--r-- | host/lib/include/uhdlib/transport/udp_common.hpp | 6 | ||||
-rw-r--r-- | host/lib/include/uhdlib/usrp/common/adf435x.hpp | 8 | ||||
-rw-r--r-- | host/lib/include/uhdlib/usrp/common/adf535x.hpp | 25 | ||||
-rw-r--r-- | host/lib/include/uhdlib/utils/isatty.hpp | 3 | ||||
-rw-r--r-- | host/lib/include/uhdlib/utils/rpc.hpp | 5 |
5 files changed, 30 insertions, 17 deletions
diff --git a/host/lib/include/uhdlib/transport/udp_common.hpp b/host/lib/include/uhdlib/transport/udp_common.hpp index 6c87ef498..c094fb142 100644 --- a/host/lib/include/uhdlib/transport/udp_common.hpp +++ b/host/lib/include/uhdlib/transport/udp_common.hpp @@ -1,6 +1,7 @@ // // Copyright 2011 Ettus Research LLC // Copyright 2018 Ettus Research, a National Instruments Company +// Copyright 2019 Ettus Research, A National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // @@ -14,6 +15,7 @@ #include <uhd/types/device_addr.hpp> #include <uhd/utils/log.hpp> #include <uhdlib/transport/links.hpp> +#include <uhdlib/utils/narrow.hpp> #include <boost/asio.hpp> #include <boost/format.hpp> #include <thread> @@ -110,7 +112,7 @@ UHD_INLINE size_t recv_udp_packet( #endif if (wait_for_recv_ready(sock_fd, timeout_ms)) { - len = ::recv(sock_fd, (char*)mem, frame_size, 0); + len = uhd::narrow_cast<ssize_t>(::recv(sock_fd, (char*)mem, frame_size, 0)); if (len == 0) { throw uhd::io_error("socket closed"); } @@ -130,7 +132,7 @@ UHD_INLINE void send_udp_packet(int sock_fd, void* mem, size_t len) // This is known to occur at least on some OSX systems. // But it should be safe to always check for the error. while (true) { - const ssize_t ret = ::send(sock_fd, (const char*)mem, len, 0); + const ssize_t ret = uhd::narrow_cast<ssize_t>(::send(sock_fd, (const char*)mem, len, 0)); if (ret == ssize_t(len)) break; if (ret == -1 and errno == ENOBUFS) { diff --git a/host/lib/include/uhdlib/usrp/common/adf435x.hpp b/host/lib/include/uhdlib/usrp/common/adf435x.hpp index 886c8d335..7989420dd 100644 --- a/host/lib/include/uhdlib/usrp/common/adf435x.hpp +++ b/host/lib/include/uhdlib/usrp/common/adf435x.hpp @@ -1,6 +1,7 @@ // // Copyright 2015 Ettus Research LLC // Copyright 2018 Ettus Research, a National Instruments Company +// Copyright 2019 Ettus Research, A National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // @@ -15,6 +16,7 @@ #include <uhd/types/ranges.hpp> #include <uhd/utils/log.hpp> #include <uhdlib/utils/math.hpp> +#include <uhdlib/utils/narrow.hpp> #include <functional> #include <boost/math/special_functions/round.hpp> #include <boost/thread.hpp> @@ -112,7 +114,8 @@ public: virtual void set_charge_pump_current(charge_pump_current_t cp_current) = 0; - virtual double set_charge_pump_current(double current, bool flush = false) = 0; + virtual double set_charge_pump_current( + const double current, const bool flush = false) = 0; virtual uhd::meta_range_t get_charge_pump_current_range() = 0; @@ -321,7 +324,8 @@ public: const auto cp_range = get_charge_pump_current_range(); const auto coerced_current = cp_range.clip(current, true); - const int current_step = std::round((coerced_current / cp_range.step()) - 1); + const int current_step = + uhd::narrow_cast<int>(std::round((coerced_current / cp_range.step()) - 1)); UHD_ASSERT_THROW(current_step >= 0 and current_step < 16); set_charge_pump_current( diff --git a/host/lib/include/uhdlib/usrp/common/adf535x.hpp b/host/lib/include/uhdlib/usrp/common/adf535x.hpp index c42f05b57..6af8556be 100644 --- a/host/lib/include/uhdlib/usrp/common/adf535x.hpp +++ b/host/lib/include/uhdlib/usrp/common/adf535x.hpp @@ -1,5 +1,6 @@ // // Copyright 2015, 2017 Ettus Research, A National Instruments Company +// Copyright 2019 Ettus Research, A National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // @@ -13,6 +14,7 @@ #include <uhd/utils/log.hpp> #include <uhd/utils/math.hpp> #include <uhd/utils/safe_call.hpp> +#include <uhdlib/utils/narrow.hpp> #include <stdint.h> #include <boost/format.hpp> #include <functional> @@ -54,22 +56,24 @@ public: MUXOUT_DLD }; - virtual void set_reference_freq(double fref, bool force = false) = 0; + virtual void set_reference_freq(const double fref, const bool force = false) = 0; - virtual void set_pfd_freq(double pfd_freq) = 0; + virtual void set_pfd_freq(const double pfd_freq) = 0; - virtual void set_feedback_select(feedback_sel_t fb_sel) = 0; + virtual void set_feedback_select(const feedback_sel_t fb_sel) = 0; - virtual void set_output_power(output_power_t power) = 0; + virtual void set_output_power(const output_power_t power) = 0; - virtual void set_output_enable(output_t output, bool enable) = 0; + virtual void set_output_enable(const output_t output, const bool enable) = 0; - virtual void set_muxout_mode(muxout_t mode) = 0; + virtual void set_muxout_mode(const muxout_t mode) = 0; - virtual double set_frequency( - double target_freq, double freq_resolution, bool flush = false) = 0; + virtual double set_frequency(const double target_freq, + const double freq_resolution, + const bool flush = false) = 0; - virtual double set_charge_pump_current(double target_current, bool flush = false) = 0; + virtual double set_charge_pump_current( + const double target_current, const bool flush = false) = 0; virtual uhd::meta_range_t get_charge_pump_current_range() = 0; @@ -238,7 +242,8 @@ public: const auto cp_range = get_charge_pump_current_range(); const auto coerced_current = cp_range.clip(current, true); - const int current_step = std::round((coerced_current / cp_range.step()) - 1); + const int current_step = + uhd::narrow_cast<int>(std::round((coerced_current / cp_range.step()) - 1)); UHD_ASSERT_THROW(current_step >= 0 and current_step < 16); _regs.charge_pump_current = diff --git a/host/lib/include/uhdlib/utils/isatty.hpp b/host/lib/include/uhdlib/utils/isatty.hpp index 1ae2c8de4..cb8d07afb 100644 --- a/host/lib/include/uhdlib/utils/isatty.hpp +++ b/host/lib/include/uhdlib/utils/isatty.hpp @@ -8,6 +8,7 @@ #define INCLUDED_UHDLIB_UTILS_ISATTY_HPP #include <uhd/config.hpp> +#include <uhdlib/utils/narrow.hpp> namespace uhd { @@ -23,7 +24,7 @@ namespace uhd { */ bool is_a_tty(const int fd) { - return _isatty(fd); + return uhd::narrow_cast<bool>(_isatty(fd)); } #elif _POSIX_C_SOURCE >= _200112L diff --git a/host/lib/include/uhdlib/utils/rpc.hpp b/host/lib/include/uhdlib/utils/rpc.hpp index 066c6d144..6a45ba61f 100644 --- a/host/lib/include/uhdlib/utils/rpc.hpp +++ b/host/lib/include/uhdlib/utils/rpc.hpp @@ -1,5 +1,6 @@ // // Copyright 2017 Ettus Research, a National Instruments Company +// Copyright 2019 Ettus Research, A National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // @@ -305,9 +306,9 @@ private: } try { return _client->call(_get_last_error_cmd).as<std::string>(); - } catch (const ::rpc::rpc_error& ex) { + } catch (const ::rpc::rpc_error&) { // nop - } catch (const std::bad_cast& ex) { + } catch (const std::bad_cast&) { // nop } catch (...) { // nop |