diff options
author | Martin Anderseck <martin.anderseck@ni.com> | 2021-08-06 20:41:48 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-08-10 12:31:45 -0500 |
commit | 807987361f2ba3df3562c24f579d02010ca47172 (patch) | |
tree | 93e03e7db14c492d9284ed07067765074c930942 /host/lib/rfnoc/mgmt_portal.cpp | |
parent | 9e55f2d39c42afbdaa849e8a338637ff5f3480ba (diff) | |
download | uhd-807987361f2ba3df3562c24f579d02010ca47172.tar.gz uhd-807987361f2ba3df3562c24f579d02010ca47172.tar.bz2 uhd-807987361f2ba3df3562c24f579d02010ca47172.zip |
lib: rfnoc: Make implicit typecasts explicit
Fix implicit typecasts that could potentially lose data. Doing this to
show that these typecasts are done on purpose (and to resolve warnings
from VS).
Diffstat (limited to 'host/lib/rfnoc/mgmt_portal.cpp')
-rw-r--r-- | host/lib/rfnoc/mgmt_portal.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/host/lib/rfnoc/mgmt_portal.cpp b/host/lib/rfnoc/mgmt_portal.cpp index 0e2ea3266..e719a9c72 100644 --- a/host/lib/rfnoc/mgmt_portal.cpp +++ b/host/lib/rfnoc/mgmt_portal.cpp @@ -10,6 +10,7 @@ #include <uhdlib/rfnoc/chdr_ctrl_xport.hpp> #include <uhdlib/rfnoc/chdr_packet_writer.hpp> #include <uhdlib/rfnoc/mgmt_portal.hpp> +#include <uhdlib/utils/narrow.hpp> #include <unordered_set> #include <boost/format.hpp> #include <cmath> @@ -1047,11 +1048,11 @@ private: // Functions chdr_header header; header.set_pkt_type(PKT_TYPE_MGMT); header.set_num_mdata(0); - header.set_seq_num(_send_seqnum++); - header.set_length(payload.get_size_bytes() + (chdr_w_to_bits(_chdr_w) / 8)); + header.set_seq_num(static_cast<uint16_t>(_send_seqnum++)); + header.set_length(uhd::narrow_cast<uint16_t>(payload.get_size_bytes() + (chdr_w_to_bits(_chdr_w) / 8))); header.set_dst_epid(0); - auto send_buff = xport.get_send_buff(timeout * 1000); + auto send_buff = xport.get_send_buff(static_cast<int32_t>(timeout * 1000)); if (not send_buff) { UHD_LOG_ERROR( "RFNOC::MGMT", "Timed out getting send buff for management transaction"); @@ -1077,7 +1078,7 @@ private: // Functions // Send the transaction over the wire _send_mgmt_transaction(xport, send); - auto mgmt_buff = xport.get_mgmt_buff(timeout * 1000); + auto mgmt_buff = xport.get_mgmt_buff(static_cast<int32_t>(timeout * 1000)); if (not mgmt_buff) { throw uhd::io_error("Timed out getting recv buff for management transaction"); } |