diff options
author | Ben Hilburn <ben.hilburn@ettus.com> | 2013-11-27 12:11:23 -0800 |
---|---|---|
committer | Ben Hilburn <ben.hilburn@ettus.com> | 2013-11-27 12:11:23 -0800 |
commit | 9e47ad607b597954e786db6614f5b42123184ccd (patch) | |
tree | f8f021498105c1144968c989b73e37d51d2e94f9 /host/utils | |
parent | 0e3912767266473e08386c910954450d16d33664 (diff) | |
download | uhd-9e47ad607b597954e786db6614f5b42123184ccd.tar.gz uhd-9e47ad607b597954e786db6614f5b42123184ccd.tar.bz2 uhd-9e47ad607b597954e786db6614f5b42123184ccd.zip |
Squashed merge of Coverity fixes.
Diffstat (limited to 'host/utils')
-rw-r--r-- | host/utils/b2xx_fx3_utils.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp index c182548b7..adacff9d0 100644 --- a/host/utils/b2xx_fx3_utils.cpp +++ b/host/utils/b2xx_fx3_utils.cpp @@ -209,7 +209,9 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { po::notify(vm); if (vm.count("help")){ - std::cout << boost::format("B2xx Utility Program %s") % visible << std::endl; + try { + std::cout << boost::format("B2xx Utility Program %s") % visible << std::endl; + } catch(...) {} return ~0; } else if (vm.count("reset-usb")) { return reset_usb(); @@ -220,10 +222,15 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { vid = B200_VENDOR_ID; // Default pid = B200_PRODUCT_ID; // Default - if (vm.count("vid")) - vid = atoh(vid_str); - if (vm.count("pid")) - pid = atoh(pid_str); + try { + if (vm.count("vid")) + vid = atoh(vid_str); + if (vm.count("pid")) + pid = atoh(pid_str); + } catch (std::exception &e) { + std::cerr << "Exception while parsing VID and PID: " << e.what() << std:: endl; + return ~0; + } // open the device handle = open_device(vid, pid); @@ -243,7 +250,11 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { std::cout << "Overwriting existing firmware" << std::endl; // reset the device - b200->reset_fx3(); + try { + b200->reset_fx3(); + } catch (std::exception &e) { + std::cerr << "Exception while reseting FX3: " << e.what() << std::endl; + } // re-open device b200.reset(); @@ -264,19 +275,24 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { if (fw_file.empty()) fw_file = uhd::find_image_path(B200_FW_FILE_NAME); - + if(fw_file.empty()) { std::cerr << "Firmware image not found!" << std::endl; return -1; } - + if(!(fs::exists(fw_file))) { std::cerr << "Invalid filepath: " << fw_file << std::endl; return -1; } // load firmware - b200->load_firmware(fw_file); + try { + b200->load_firmware(fw_file); + } catch (std::exception &e) { + std::cerr << "Exception while loading firmware: " << e.what() << std::endl; + return ~0; + } // re-open device b200.reset(); @@ -403,7 +419,7 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { try { b200->reset_fx3(); } catch (const std::exception &e) { - std::cerr << "Exceptions while resetting device: " << e.what() << std::endl; + std::cerr << "Exception while resetting device: " << e.what() << std::endl; return -1; } @@ -461,7 +477,9 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { << std::endl; } else { - std::cout << boost::format("B2xx Utility Program %s") % visible << std::endl; + try { + std::cout << boost::format("B2xx Utility Program %s") % visible << std::endl; + } catch(...) {} return ~0; } |