From 6d7692f393b9d1e5e75b8239a3249ee02e0441d9 Mon Sep 17 00:00:00 2001 From: Andrej Rode Date: Fri, 16 Dec 2016 10:40:00 -0800 Subject: usrp2: fixes according to coverity reports --- host/utils/usrp_n2xx_simple_net_burner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'host/utils') diff --git a/host/utils/usrp_n2xx_simple_net_burner.cpp b/host/utils/usrp_n2xx_simple_net_burner.cpp index 56af3ce4a..f85ea9def 100644 --- a/host/utils/usrp_n2xx_simple_net_burner.cpp +++ b/host/utils/usrp_n2xx_simple_net_burner.cpp @@ -326,7 +326,7 @@ int read_fpga_image(std::string& fpga_path){ fpga_file.seekg(0, std::ios::beg); fpga_file.read((char*)fpga_test_bytes,63); bool is_good = false; - for(int i = 0; i < 63; i++){ + for(int i = 0; i < 62; i++){ if(fpga_test_bytes[i] == 255) continue; else if(fpga_test_bytes[i] == 170 and fpga_test_bytes[i+1] == 153){ -- cgit v1.2.3 From 797249bf725051a07ad128b27a7f01d7be86f01c Mon Sep 17 00:00:00 2001 From: Andrej Rode Date: Fri, 16 Dec 2016 17:42:40 -0800 Subject: utils: tests: cast RAND_MAX to double before division --- host/tests/convert_test.cpp | 4 ++-- host/utils/converter_benchmark.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'host/utils') diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp index 6c1b94c45..dd04dcafc 100644 --- a/host/tests/convert_test.cpp +++ b/host/tests/convert_test.cpp @@ -285,8 +285,8 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ const size_t nsamps = 13; std::vector input(nsamps); BOOST_FOREACH(fc32_t &in, input) in = fc32_t( - (std::rand()/float(RAND_MAX/2)) - 1, - (std::rand()/float(RAND_MAX/2)) - 1 + (std::rand()/(RAND_MAX/2.0)) - 1, + (std::rand()/(RAND_MAX/2.0)) - 1 ); std::vector interm(nsamps); std::vector output(nsamps); diff --git a/host/utils/converter_benchmark.cpp b/host/utils/converter_benchmark.cpp index c0cd28440..f6d7e9650 100644 --- a/host/utils/converter_benchmark.cpp +++ b/host/utils/converter_benchmark.cpp @@ -82,8 +82,8 @@ void init_random_vector_complex_float(std::vector &buf_ptr, const size_t n std::complex * const buf = reinterpret_cast * const>(&buf_ptr[0]); for (size_t i = 0; i < n_items; i++) { buf[i] = std::complex( - T((std::rand()/double(RAND_MAX/2)) - 1), - T((std::rand()/double(RAND_MAX/2)) - 1) + T(std::rand()/(RAND_MAX/2.0) - 1), + T(std::rand()/(RAND_MAX/2.0) - 1) ); } } -- cgit v1.2.3