diff options
author | RALOVICH, Kristof <tade60@freemail.hu> | 2015-05-31 19:15:04 +0200 |
---|---|---|
committer | RALOVICH, Kristof <tade60@freemail.hu> | 2015-05-31 19:15:04 +0200 |
commit | 3f35b848ae65ecc6c1c481f0f35f79554506b246 (patch) | |
tree | 924f5741b3af9c1c7778a1c14b2b95c8c3dd3588 | |
parent | def2ff2888eb6caa81e4c9c35e7946fc00980dd5 (diff) | |
parent | b96cfcf75d0182b4b4f589d376f220d7c908f83c (diff) |
Merge branch 'master' into coverity_scancoverity_scan
-rw-r--r-- | src/SerialTty.cpp | 12 | ||||
-rw-r--r-- | src/antpm-downloader.cpp | 5 | ||||
-rw-r--r-- | src/antpm-fit2gpx.cpp | 16 | ||||
-rw-r--r-- | src/antpm-usbmon2ant.cpp | 6 | ||||
-rw-r--r-- | src/gant/gant.c | 8 |
5 files changed, 39 insertions, 8 deletions
diff --git a/src/SerialTty.cpp b/src/SerialTty.cpp index 65e4415..7126eff 100644 --- a/src/SerialTty.cpp +++ b/src/SerialTty.cpp @@ -173,7 +173,9 @@ SerialTtyPrivate::guessDeviceName(vector<string> &guessedNames) std::ifstream mods("/proc/modules"); bool cp210x_found=false; if(!mods.is_open()) + { LOG(LOG_WARN) << "Could not open /proc/modules!\n"; + } else { while (mods.good()) @@ -184,9 +186,13 @@ SerialTtyPrivate::guessDeviceName(vector<string> &guessedNames) } mods.close(); if(cp210x_found) + { LOG(LOG_DBG) << "Found loaded cp210x kernel module, good.\n"; + } else + { LOG(LOG_WARN) << "cp210x is not listed among loaded kernel modules!\n"; + } } // check for usb ids inside /sys/bus/usb/devices/N-N/idProduct|idVendor @@ -195,7 +201,9 @@ SerialTtyPrivate::guessDeviceName(vector<string> &guessedNames) // check /sys/bus/usb/drivers/cp210x/6-2:1.0/interface for "Dynastream ANT2USB" const char* driverDir="/sys/bus/usb/drivers/cp210x"; if(!folderExists(driverDir)) + { LOG(LOG_WARN) << driverDir << " doesn't exist!\n"; + } else { LOG(LOG_DBG) << "Detecting in " << driverDir << " ...\n"; @@ -320,10 +328,10 @@ SerialTty::~SerialTty() #define ENSURE_OR_RETURN_FALSE(e) \ do \ { \ - if(-1 == (e)) \ + if((e)<0) \ { \ /*perror(#e);*/ \ - const char* se=strerror(e); \ + const char* se=strerror(errno); \ LOG(antpm::LOG_ERR) << se << "\n"; \ return false; \ } \ diff --git a/src/antpm-downloader.cpp b/src/antpm-downloader.cpp index 6c7f5d9..1bdea95 100644 --- a/src/antpm-downloader.cpp +++ b/src/antpm-downloader.cpp @@ -186,6 +186,11 @@ main(int argc, char** argv) cerr << desc << "\n"; return EXIT_FAILURE; } + catch(boost::exception& e) + { + cerr << boost::diagnostic_information(e) << std::endl; + return EXIT_FAILURE; + } catch(std::exception& ex) { cerr << ex.what() << "\n"; diff --git a/src/antpm-fit2gpx.cpp b/src/antpm-fit2gpx.cpp index d78b25f..c5974f1 100644 --- a/src/antpm-fit2gpx.cpp +++ b/src/antpm-fit2gpx.cpp @@ -29,6 +29,7 @@ #include <boost/program_options.hpp> #include <boost/filesystem.hpp> +#include <boost/exception/diagnostic_information.hpp> namespace po = boost::program_options; namespace fs = boost::filesystem; @@ -91,7 +92,11 @@ main(int argc, char** argv) bool fixLastWrt = false; int verbosityLevel = antpm::Log::instance()->getLogReportingLevel(); po::options_description desc("Allowed options"); - desc.add_options() + std::vector<const char*> args(argv, argv+argc); + po::variables_map vm; + try + { + desc.add_options() ("help,h", "produce help message") ("fitFolder,F", po::value<std::string>(&fitFolder), "Folder with FIT files") ("decode-fit-root,D", po::value<std::string>(&fitRootFile), "FIT file, encoding the root directory contents on a device, e.g. /tmp/0000.fit") @@ -100,10 +105,6 @@ main(int argc, char** argv) ("version,V", "Print version information") ; - std::vector<const char*> args(argv, argv+argc); - po::variables_map vm; - try - { //po::parsed_options parsed = po::parse_command_line(argc, argv, desc); po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).run(); po::store(parsed, vm); @@ -115,6 +116,11 @@ main(int argc, char** argv) cerr << desc << "\n"; return EXIT_FAILURE; } + catch(boost::exception& e) + { + cerr << boost::diagnostic_information(e) << std::endl; + return EXIT_FAILURE; + } catch(std::exception& ex) { cerr << ex.what() << "\n"; diff --git a/src/antpm-usbmon2ant.cpp b/src/antpm-usbmon2ant.cpp index a7aae53..68e4192 100644 --- a/src/antpm-usbmon2ant.cpp +++ b/src/antpm-usbmon2ant.cpp @@ -27,6 +27,7 @@ #include "Log.hpp" #include <boost/program_options.hpp> +#include <boost/exception/diagnostic_information.hpp> namespace po = boost::program_options; using namespace std; @@ -90,6 +91,11 @@ main(int argc, char** argv) cerr << desc << "\n"; return EXIT_FAILURE; } + catch(boost::exception& e) + { + cerr << boost::diagnostic_information(e) << std::endl; + return EXIT_FAILURE; + } catch(std::exception& ex) { cerr << ex.what() << "\n"; diff --git a/src/gant/gant.c b/src/gant/gant.c index 5586f99..c4e1b7c 100644 --- a/src/gant/gant.c +++ b/src/gant/gant.c @@ -196,11 +196,17 @@ uint randno(void) if (fd >= 0) { - read(fd, &r, sizeof r); + ssize_t rr = read(fd, &r, sizeof r); close(fd); + if(rr != sizeof r) + { + r = rand(); + } } else + { r = rand(); + } return r; } |