From 1200721b696751edaceb70a332861f84fb8c16d5 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Fri, 27 Mar 2015 09:35:29 -0700 Subject: Warning fixes * CMake now not applying C++ flags to C files * GCC 4.4: anti-aliasing rules * MSVC: narrowing, differences in subclass function parameters * Clang: uninitialized variables --- host/examples/rx_samples_to_file.cpp | 2 +- host/examples/test_clock_synch.cpp | 14 +++++++------- host/examples/tx_samples_from_file.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'host/examples') diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 975a9da88..80b72de9c 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -64,7 +64,7 @@ template void recv_to_file( uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS: uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE ); - stream_cmd.num_samps = num_requested_samples; + stream_cmd.num_samps = size_t(num_requested_samples); stream_cmd.stream_now = true; stream_cmd.time_spec = uhd::time_spec_t(); rx_stream->issue_stream_cmd(stream_cmd); diff --git a/host/examples/test_clock_synch.cpp b/host/examples/test_clock_synch.cpp index 7a4226345..9d1883665 100644 --- a/host/examples/test_clock_synch.cpp +++ b/host/examples/test_clock_synch.cpp @@ -35,14 +35,14 @@ using namespace uhd::usrp_clock; using namespace uhd::usrp; void wait_for_pps(multi_usrp::sptr usrp, size_t chan, double timeout){ - boost::uint32_t last_pps_time = usrp->get_time_last_pps(chan).get_full_secs(); - boost::uint32_t system_time = uhd::time_spec_t::get_system_time().get_full_secs(); - boost::uint32_t exit_time = system_time + timeout; + time_t last_pps_time = usrp->get_time_last_pps(chan).get_full_secs(); + time_t system_time = uhd::time_spec_t::get_system_time().get_full_secs(); + time_t exit_time = system_time + time_t(timeout); bool detected_pps = false; //Otherwise, this would hang if the USRP doesn't detect any PPS while(uhd::time_spec_t::get_system_time().get_full_secs() < exit_time){ - boost::uint32_t time_now = usrp->get_time_last_pps(chan).get_full_secs(); + time_t time_now = usrp->get_time_last_pps(chan).get_full_secs(); if(last_pps_time < time_now){ detected_pps = true; break; @@ -54,7 +54,7 @@ void wait_for_pps(multi_usrp::sptr usrp, size_t chan, double timeout){ } -void get_usrp_time(multi_usrp::sptr usrp, size_t chan, std::vector *times){ +void get_usrp_time(multi_usrp::sptr usrp, size_t chan, std::vector *times){ wait_for_pps(usrp, chan, 2); (*times)[chan] = usrp->get_time_now(chan).get_full_secs(); } @@ -130,7 +130,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //Wait for next PPS to start polling wait_for_pps(usrp, 0, 2); - srand(time(NULL)); + srand((unsigned int)time(NULL)); std::cout << boost::format("\nRunning %d comparisons at random intervals.") % num_tests << std::endl << std::endl; boost::uint32_t num_matches = 0; @@ -140,7 +140,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ boost::this_thread::sleep(boost::posix_time::milliseconds(wait_time)); //Get all times before output - std::vector usrp_times(usrp->get_num_mboards()); + std::vector usrp_times(usrp->get_num_mboards()); boost::thread_group thread_group; clock_time = clock->get_time(); for(size_t j = 0; j < usrp->get_num_mboards(); j++){ diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index e9d0e8721..cc7e963d5 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -55,7 +55,7 @@ template void send_from_file( while(not md.end_of_burst and not stop_signal_called){ infile.read((char*)&buff.front(), buff.size()*sizeof(samp_type)); - size_t num_tx_samps = infile.gcount()/sizeof(samp_type); + size_t num_tx_samps = size_t(infile.gcount()/sizeof(samp_type)); md.end_of_burst = infile.eof(); @@ -104,7 +104,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ return ~0; } - bool repeat = vm.count("repeat"); + bool repeat = vm.count("repeat") > 0; //create a usrp device std::cout << std::endl; -- cgit v1.2.3 From 715f4dd313656f936e40b6415179b7ab6feda128 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Fri, 27 Mar 2015 10:55:48 -0700 Subject: Fixed master-specific warnings * MinGW: unused parameter warning, MSVC-specific pragma * MSVC: bool narrowing --- host/examples/benchmark_rate.cpp | 2 +- host/include/uhd/config.hpp | 4 ++-- host/include/uhd/transport/nirio/nirio_driver_iface.h | 10 +++++++--- host/lib/transport/chdr.cpp | 6 +++--- host/lib/utils/thread_priority.cpp | 2 +- host/tests/chdr_test.cpp | 5 ++++- 6 files changed, 18 insertions(+), 11 deletions(-) (limited to 'host/examples') diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 7ff8b9939..cc3ef04a4 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -142,7 +142,7 @@ void benchmark_tx_rate( md.has_time_spec = (buffs.size() != 1); if (random_nsamps) { - std::srand( time(NULL) ); + std::srand( (unsigned int)time(NULL) ); while(not boost::this_thread::interruption_requested()){ size_t total_num_samps = rand() % max_samps_per_packet; size_t num_acc_samps = 0; diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 23eb9cdb2..8939cd773 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2011,2014 Ettus Research LLC +// Copyright 2010-2011,2014-2015 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -62,7 +62,7 @@ typedef ptrdiff_t ssize_t; #define UHD_INLINE inline #define UHD_DEPRECATED __declspec(deprecated) #define UHD_ALIGNED(x) __declspec(align(x)) - #define UHD_UNUSED(x) x + #define UHD_UNUSED(x) x __attribute__((unused)) #elif defined(__GNUG__) && __GNUG__ >= 4 #define UHD_EXPORT __attribute__((visibility("default"))) #define UHD_IMPORT __attribute__((visibility("default"))) diff --git a/host/include/uhd/transport/nirio/nirio_driver_iface.h b/host/include/uhd/transport/nirio/nirio_driver_iface.h index 3e0e56a7f..c562f0ca5 100644 --- a/host/include/uhd/transport/nirio/nirio_driver_iface.h +++ b/host/include/uhd/transport/nirio/nirio_driver_iface.h @@ -1,5 +1,5 @@ // -// Copyright 2013-2014 Ettus Research LLC +// Copyright 2013-2015 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -25,9 +25,13 @@ #include #if defined(UHD_PLATFORM_WIN32) #include - #pragma warning(disable:4201) // nonstandard extension used : nameless struct/union + #ifdef _MSC_VER + #pragma warning(disable:4201) // nonstandard extension used : nameless struct/union + #endif #include - #pragma warning(default:4201) + #ifdef _MSC_VER + #pragma warning(default:4201) + #endif #elif !defined(UHD_PLATFORM_LINUX) #include #endif diff --git a/host/lib/transport/chdr.cpp b/host/lib/transport/chdr.cpp index 47ac961b9..632887e56 100644 --- a/host/lib/transport/chdr.cpp +++ b/host/lib/transport/chdr.cpp @@ -115,12 +115,12 @@ UHD_INLINE void _hdr_unpack_chdr( if_packet_info.sob = false; // Set configurable members - if_packet_info.has_tsf = bool(chdr & HDR_FLAG_TSF); + if_packet_info.has_tsf = (chdr & HDR_FLAG_TSF) > 0; if_packet_info.packet_type = if_packet_info_t::packet_type_t((chdr >> 30) & 0x3); if_packet_info.eob = (if_packet_info.packet_type == if_packet_info_t::PACKET_TYPE_DATA) - && bool(chdr & HDR_FLAG_EOB); + && ((chdr & HDR_FLAG_EOB) > 0); if_packet_info.error = (if_packet_info.packet_type == if_packet_info_t::PACKET_TYPE_RESP) - && bool(chdr & HDR_FLAG_ERROR); + && ((chdr & HDR_FLAG_ERROR) > 0); if_packet_info.packet_count = (chdr >> 16) & 0xFFF; // Set packet length variables diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp index 7c3faa37a..af25d088a 100644 --- a/host/lib/utils/thread_priority.cpp +++ b/host/lib/utils/thread_priority.cpp @@ -74,7 +74,7 @@ static void check_priority_range(float priority){ #ifdef HAVE_WIN_SETTHREADPRIORITY #include - void uhd::set_thread_priority(float priority, bool realtime){ + void uhd::set_thread_priority(float priority, UHD_UNUSED(bool realtime)){ check_priority_range(priority); /* diff --git a/host/tests/chdr_test.cpp b/host/tests/chdr_test.cpp index ed6c690f9..f48073a09 100644 --- a/host/tests/chdr_test.cpp +++ b/host/tests/chdr_test.cpp @@ -47,7 +47,10 @@ static void pack_and_unpack( ); std::cout << std::endl; boost::uint32_t header_bits = (uhd::ntohx(packet_buff[0]) >> 28); - std::cout << boost::format("header bits = 0b%d%d%d%d") % bool(header_bits & 8) % bool(header_bits & 4) % bool(header_bits & 2) % bool(header_bits & 1) << std::endl; + std::cout << boost::format("header bits = 0b%d%d%d%d") % ((header_bits & 8) > 0) + % ((header_bits & 4) > 0) + % ((header_bits & 2) > 0) + % ((header_bits & 1) > 0) << std::endl; for (size_t i = 0; i < 5; i++) { std::cout << boost::format("packet_buff[%u] = 0x%08x") % i % uhd::ntohx(packet_buff[i]) << std::endl; -- cgit v1.2.3