[Positioning] Check code with cppcheck
- Replace occurences of `container.size() == 0` with `container.empty()`. - Fix an allocation in posexcept.cc (false positive?). - UserInterface: in constructor, handle bad_alloc exception possibly thrown by `new`.
This commit is contained in:
parent
bc46fc1af2
commit
7264080536
|
@ -95,7 +95,7 @@ void Measurement::clear()
|
||||||
|
|
||||||
void Measurement::update_average_ss()
|
void Measurement::update_average_ss()
|
||||||
{
|
{
|
||||||
if (ss_list.size() == 0)
|
if (ss_list.empty())
|
||||||
{
|
{
|
||||||
average_ss = 0 ;
|
average_ss = 0 ;
|
||||||
return ;
|
return ;
|
||||||
|
@ -151,7 +151,7 @@ ostream &operator<<(ostream &os, const Measurement &m)
|
||||||
<< ": " ;
|
<< ": " ;
|
||||||
|
|
||||||
// List of SS
|
// List of SS
|
||||||
if (m.ss_list.size() == 0)
|
if (m.ss_list.empty())
|
||||||
os << "No values" ;
|
os << "No values" ;
|
||||||
else
|
else
|
||||||
for (vector<int>::const_iterator i = m.ss_list.begin() ;
|
for (vector<int>::const_iterator i = m.ss_list.begin() ;
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
|
|
||||||
bad_direction::bad_direction(const char _direction) throw():
|
bad_direction::bad_direction(const char _direction) throw()
|
||||||
direction(_direction) {}
|
{
|
||||||
|
direction = _direction ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* bad_direction::what() const throw()
|
const char* bad_direction::what() const throw()
|
||||||
|
|
|
@ -159,7 +159,7 @@ ostream &operator<<(ostream &os, const ReferencePoint &rp)
|
||||||
os << (Point3D) rp << '\n' ;
|
os << (Point3D) rp << '\n' ;
|
||||||
|
|
||||||
// List of requests
|
// List of requests
|
||||||
if (rp.requests.size() == 0)
|
if (rp.requests.empty())
|
||||||
os << "No request." << '\n' ;
|
os << "No request." << '\n' ;
|
||||||
else
|
else
|
||||||
for (vector<CalibrationRequest*>::const_iterator
|
for (vector<CalibrationRequest*>::const_iterator
|
||||||
|
|
|
@ -112,7 +112,7 @@ ostream &operator<<(ostream &os, const Request &r)
|
||||||
<< ":" ;
|
<< ":" ;
|
||||||
|
|
||||||
// List of Measurements
|
// List of Measurements
|
||||||
if (r.measurements.size() == 0)
|
if (r.measurements.empty())
|
||||||
os << " No values" ;
|
os << " No values" ;
|
||||||
else
|
else
|
||||||
for (unordered_map<string, Measurement>::const_iterator i
|
for (unordered_map<string, Measurement>::const_iterator i
|
||||||
|
|
|
@ -26,8 +26,16 @@ UserInterface::UserInterface(const int argc, char **argv)
|
||||||
cli_argument_values = argv ;
|
cli_argument_values = argv ;
|
||||||
config_file_name = DEFAULT_CONFIG_FILE_NAME ;
|
config_file_name = DEFAULT_CONFIG_FILE_NAME ;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
cli_options = new po::options_description("General options") ;
|
cli_options = new po::options_description("General options") ;
|
||||||
file_options = new po::options_description("Parameters") ;
|
file_options = new po::options_description("Parameters") ;
|
||||||
|
}
|
||||||
|
catch (bad_alloc e)
|
||||||
|
{
|
||||||
|
throw ;
|
||||||
|
}
|
||||||
|
|
||||||
fill_options() ;
|
fill_options() ;
|
||||||
|
|
||||||
parse_options() ;
|
parse_options() ;
|
||||||
|
|
|
@ -80,7 +80,7 @@ ostream &operator<<(ostream &os, const Waypoint &wp)
|
||||||
os << (Point3D) wp ;
|
os << (Point3D) wp ;
|
||||||
|
|
||||||
// List of buildings
|
// List of buildings
|
||||||
if (wp.buildings.size() == 0)
|
if (wp.buildings.empty())
|
||||||
os << '\n' << "Belongs to no building!" ;
|
os << '\n' << "Belongs to no building!" ;
|
||||||
else
|
else
|
||||||
for (vector<Building*>::const_iterator i = wp.buildings.begin() ;
|
for (vector<Building*>::const_iterator i = wp.buildings.begin() ;
|
||||||
|
|
Loading…
Reference in New Issue