From 967be2a4e82b1a125b26bb72a60318a4fb2b50c4 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Mon, 14 Jan 2019 10:35:25 -0800 Subject: uhd: mpm: apply clang-format to all files Applying formatting changes to all .cpp and .hpp files in the following directories: ``` find host/examples/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/tests/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/utils/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find mpm/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Also formatted host/include/, except Cpp03 was used as a the language standard instead of Cpp11. ``` sed -i 's/ Cpp11/ Cpp03/g' .clang-format find host/include/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Formatting style was designated by the .clang-format file. --- host/utils/uhd_image_loader.cpp | 86 +++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 41 deletions(-) (limited to 'host/utils/uhd_image_loader.cpp') diff --git a/host/utils/uhd_image_loader.cpp b/host/utils/uhd_image_loader.cpp index 507a4ac87..57ad57958 100644 --- a/host/utils/uhd_image_loader.cpp +++ b/host/utils/uhd_image_loader.cpp @@ -5,47 +5,49 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#include -#include -#include - -#include -#include -#include - #include #include #include #include +#include +#include +#include #include +#include +#include +#include namespace fs = boost::filesystem; namespace po = boost::program_options; static std::string device_type = ""; -static int num_ctrl_c = 0; +static int num_ctrl_c = 0; /* * If the user presses Ctrl+C, warn them that they may corrupt their device. * If they press it again, provide instructions on restoring the device * (if applicable) and exit. */ -void sigint_handler(int){ +void sigint_handler(int) +{ num_ctrl_c++; - if(num_ctrl_c == 1){ + if (num_ctrl_c == 1) { std::cout << std::endl - << "Are you sure you want to abort? If you do, your device will likely" << std::endl + << "Are you sure you want to abort? If you do, your device will likely" + << std::endl << "be in an unstable or unusable state." << std::endl - << "Press Ctrl+C again to abort." << std::endl << std::endl; - } - else{ - std::cout << std::endl << uhd::image_loader::get_recovery_instructions(device_type) << std::endl; + << "Press Ctrl+C again to abort." << std::endl + << std::endl; + } else { + std::cout << std::endl + << uhd::image_loader::get_recovery_instructions(device_type) + << std::endl; exit(EXIT_FAILURE); } } -int UHD_SAFE_MAIN(int argc, char *argv[]){ - +int UHD_SAFE_MAIN(int argc, char* argv[]) +{ po::options_description desc("Allowed options"); // clang-format off desc.add_options() @@ -65,10 +67,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ po::notify(vm); // Help message - if (vm.count("help")){ + if (vm.count("help")) { std::cout << "UHD Image Loader" << std::endl << std::endl - << "Load firmware and/or FPGA images onto an Ettus Research device." << std::endl + << "Load firmware and/or FPGA images onto an Ettus Research device." + << std::endl << std::endl << desc << std::endl; return EXIT_FAILURE; @@ -77,49 +80,50 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ // Convert user options uhd::image_loader::image_loader_args_t image_loader_args; image_loader_args.args = vm["args"].as(); - image_loader_args.load_firmware = (vm.count("no-fw") == 0); - image_loader_args.load_fpga = (vm.count("no-fpga") == 0); + image_loader_args.load_firmware = (vm.count("no-fw") == 0); + image_loader_args.load_fpga = (vm.count("no-fpga") == 0); image_loader_args.download = (vm.count("download") != 0); image_loader_args.firmware_path = vm["fw-path"].as(); image_loader_args.fpga_path = vm["fpga-path"].as(); image_loader_args.out_path = vm["out-path"].as(); // Force user to specify a device - if(not image_loader_args.args.has_key("type")){ + if (not image_loader_args.args.has_key("type")) { throw uhd::runtime_error("You must specify a device type."); } // Clean up paths, if given - if(image_loader_args.firmware_path != ""){ - #ifndef UHD_PLATFORM_WIN32 - if(image_loader_args.firmware_path.find("~") == 0){ - image_loader_args.firmware_path.replace(0,1,getenv("HOME")); + if (image_loader_args.firmware_path != "") { +#ifndef UHD_PLATFORM_WIN32 + if (image_loader_args.firmware_path.find("~") == 0) { + image_loader_args.firmware_path.replace(0, 1, getenv("HOME")); } - #endif /* UHD_PLATFORM_WIN32 */ - image_loader_args.firmware_path = fs::absolute(image_loader_args.firmware_path).string(); +#endif /* UHD_PLATFORM_WIN32 */ + image_loader_args.firmware_path = + fs::absolute(image_loader_args.firmware_path).string(); } - if(image_loader_args.fpga_path != ""){ - #ifndef UHD_PLATFORM_WIN32 - if(image_loader_args.fpga_path.find("~") == 0){ - image_loader_args.fpga_path.replace(0,1,getenv("HOME")); + if (image_loader_args.fpga_path != "") { +#ifndef UHD_PLATFORM_WIN32 + if (image_loader_args.fpga_path.find("~") == 0) { + image_loader_args.fpga_path.replace(0, 1, getenv("HOME")); } - #endif /* UHD_PLATFORM_WIN32 */ +#endif /* UHD_PLATFORM_WIN32 */ image_loader_args.fpga_path = fs::absolute(image_loader_args.fpga_path).string(); } - if(image_loader_args.out_path != ""){ - #ifndef UHD_PLATFORM_WIN32 - if(image_loader_args.out_path.find("~") == 0){ - image_loader_args.out_path.replace(0,1,getenv("HOME")); + if (image_loader_args.out_path != "") { +#ifndef UHD_PLATFORM_WIN32 + if (image_loader_args.out_path.find("~") == 0) { + image_loader_args.out_path.replace(0, 1, getenv("HOME")); } - #endif /* UHD_PLATFORM_WIN32 */ +#endif /* UHD_PLATFORM_WIN32 */ image_loader_args.out_path = fs::absolute(image_loader_args.out_path).string(); } // Detect which type of device we're working with - device_type = image_loader_args.args.get("type",""); + device_type = image_loader_args.args.get("type", ""); std::signal(SIGINT, &sigint_handler); - if(not uhd::image_loader::load(image_loader_args)){ + if (not uhd::image_loader::load(image_loader_args)) { std::cerr << "No applicable UHD devices found" << std::endl; return EXIT_FAILURE; } -- cgit v1.2.3