From 44fbbdf1a0366bff551062cb93fc68a7d1c10112 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 20 Apr 2020 18:01:19 +0000 Subject: [PATCH] Fight warnings (c++-11 and newer) --- src/COORM/BatchManager_COORM.cxx | 3 +++ src/Core/Constants.hxx | 1 + src/Core/Test/SimpleParser.cxx | 26 ++++++++++---------- src/Core/Test/SimpleParser.hxx | 26 ++++++++++---------- src/Core/Test/Test_SimpleParser.cxx | 2 +- src/Core/Versatile.cxx | 38 ++++++++++++++--------------- src/Core/Versatile.hxx | 38 ++++++++++++++--------------- src/OAR/BatchManager_OAR.cxx | 1 + 8 files changed, 70 insertions(+), 65 deletions(-) diff --git a/src/COORM/BatchManager_COORM.cxx b/src/COORM/BatchManager_COORM.cxx index 5676073..9fbbabd 100644 --- a/src/COORM/BatchManager_COORM.cxx +++ b/src/COORM/BatchManager_COORM.cxx @@ -179,6 +179,9 @@ namespace Batch int edt = 0; int mem = 0; string queue = ""; + LIBBATCH_UNUSED(nbproc); + LIBBATCH_UNUSED(edt); + LIBBATCH_UNUSED(mem); // Mandatory parameters if (params.find(WORKDIR) != params.end()) diff --git a/src/Core/Constants.hxx b/src/Core/Constants.hxx index 591f248..b29fdc4 100644 --- a/src/Core/Constants.hxx +++ b/src/Core/Constants.hxx @@ -39,6 +39,7 @@ // TODO: replace those static declarations by an external description file (XML for instance) #define decl_extern_Constant(constant) extern BATCH_EXPORT const std::string constant #define def_Constant(constant) const std::string constant = #constant +#define LIBBATCH_UNUSED(var) (void)var namespace Batch { diff --git a/src/Core/Test/SimpleParser.cxx b/src/Core/Test/SimpleParser.cxx index 28360fd..343469d 100644 --- a/src/Core/Test/SimpleParser.cxx +++ b/src/Core/Test/SimpleParser.cxx @@ -38,31 +38,31 @@ using namespace std; -ParserException::ParserException(string msg) throw() +ParserException::ParserException(string msg) noexcept : exception(), _msg(msg) { } -ParserException::~ParserException() throw() +ParserException::~ParserException() noexcept { } -const char * ParserException::what() const throw() +const char * ParserException::what() const noexcept { return _msg.c_str(); } -SimpleParser::SimpleParser() throw() +SimpleParser::SimpleParser() noexcept { } -SimpleParser::~SimpleParser() throw() +SimpleParser::~SimpleParser() noexcept { } -std::string SimpleParser::trim(const std::string & str) const throw() +std::string SimpleParser::trim(const std::string & str) const noexcept { size_t beg = str.find_first_not_of(" \t"); if (beg == string::npos) beg = 0; @@ -70,7 +70,7 @@ std::string SimpleParser::trim(const std::string & str) const throw() return str.substr(beg, end-beg+1); } -void SimpleParser::parse(const string & filename) throw(ParserException) +void SimpleParser::parse(const string & filename) { ifstream fileStream(filename.c_str()); if (!fileStream) { @@ -109,7 +109,7 @@ void SimpleParser::parse(const string & filename) throw(ParserException) fileStream.close(); } -void SimpleParser::parseTestConfigFile() throw(ParserException) +void SimpleParser::parseTestConfigFile() { char * filename = getenv(TEST_CONFIG_FILE_ENV_VAR); if (filename == NULL) { @@ -119,7 +119,7 @@ void SimpleParser::parseTestConfigFile() throw(ParserException) } } -const string & SimpleParser::getValue(const string & key) const throw(ParserException) +const string & SimpleParser::getValue(const string & key) const { map::const_iterator iter = _configmap.find(key); if (iter == _configmap.end()) { @@ -129,7 +129,7 @@ const string & SimpleParser::getValue(const string & key) const throw(ParserExce } const string & SimpleParser::getTestValue(const string & bmType, const string & protocolStr, - const string & key) const throw(ParserException) + const string & key) const { string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key; try { @@ -143,7 +143,7 @@ const string & SimpleParser::getTestValue(const string & bmType, const string & return getValue(fullkey); } -int SimpleParser::getValueAsInt(const string & key) const throw(ParserException) +int SimpleParser::getValueAsInt(const string & key) const { const string & valueStr = getValue(key); const char * valueCStr = valueStr.c_str(); @@ -156,7 +156,7 @@ int SimpleParser::getValueAsInt(const string & key) const throw(ParserException) } int SimpleParser::getTestValueAsInt(const string & bmType, const string & protocolStr, - const string & key) const throw(ParserException) + const string & key) const { string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key; try { @@ -170,7 +170,7 @@ int SimpleParser::getTestValueAsInt(const string & bmType, const string & protoc return getValueAsInt(fullkey); } -ostream & operator <<(ostream & os, const SimpleParser & parser) throw() +ostream & operator <<(ostream & os, const SimpleParser & parser) noexcept { if (parser._configmap.empty()) { os << "Empty map" << endl; diff --git a/src/Core/Test/SimpleParser.hxx b/src/Core/Test/SimpleParser.hxx index ec0f0b0..fb31424 100644 --- a/src/Core/Test/SimpleParser.hxx +++ b/src/Core/Test/SimpleParser.hxx @@ -36,10 +36,10 @@ class ParserException : public std::exception { public: - ParserException(std::string msg) throw(); - virtual ~ParserException() throw(); + ParserException(std::string msg) noexcept; + virtual ~ParserException() noexcept; - virtual const char *what() const throw(); + virtual const char *what() const noexcept; private: std::string _msg; @@ -48,22 +48,22 @@ private: class SimpleParser { public: - SimpleParser() throw(); - virtual ~SimpleParser() throw(); + SimpleParser() noexcept; + virtual ~SimpleParser() noexcept; - void parse(const std::string & filename) throw(ParserException); - void parseTestConfigFile() throw(ParserException); - const std::string & getValue(const std::string & key) const throw(ParserException); + void parse(const std::string & filename); + void parseTestConfigFile(); + const std::string & getValue(const std::string & key) const; const std::string & getTestValue(const std::string & bmType, const std::string & protocolStr, - const std::string & key) const throw(ParserException); - int getValueAsInt(const std::string & key) const throw(ParserException); + const std::string & key) const; + int getValueAsInt(const std::string & key) const; int getTestValueAsInt(const std::string & bmType, const std::string & protocolStr, - const std::string & key) const throw(ParserException); + const std::string & key) const; - friend std::ostream & operator <<(std::ostream & os, const SimpleParser & parser) throw(); + friend std::ostream & operator <<(std::ostream & os, const SimpleParser & parser) noexcept; private: - std::string trim(const std::string & str) const throw(); + std::string trim(const std::string & str) const noexcept; std::map _configmap; }; diff --git a/src/Core/Test/Test_SimpleParser.cxx b/src/Core/Test/Test_SimpleParser.cxx index f635e42..ac6f749 100644 --- a/src/Core/Test/Test_SimpleParser.cxx +++ b/src/Core/Test/Test_SimpleParser.cxx @@ -49,7 +49,7 @@ int main(int argc, char** argv) try { // Parse the configuration file parser.parseTestConfigFile(); - } catch (ParserException e) { + } catch (const ParserException& e) { cerr << "Parser error: " << e.what() << endl; return 1; } diff --git a/src/Core/Versatile.cxx b/src/Core/Versatile.cxx index 010849b..9828973 100644 --- a/src/Core/Versatile.cxx +++ b/src/Core/Versatile.cxx @@ -66,7 +66,7 @@ namespace Batch { eraseAll(); } - Versatile & Versatile::operator = (const long l) throw(TypeMismatchException) + Versatile & Versatile::operator = (const long l) { checkType(LONG); eraseAll(); @@ -74,7 +74,7 @@ namespace Batch { return *this; } - Versatile & Versatile::operator = (const string & ch) throw(TypeMismatchException) + Versatile & Versatile::operator = (const string & ch) { checkType(STRING); eraseAll(); @@ -82,7 +82,7 @@ namespace Batch { return *this; } - Versatile & Versatile::operator +=(const string & ch) throw(TypeMismatchException,ListIsFullException) + Versatile & Versatile::operator +=(const string & ch) { checkType(STRING); @@ -97,28 +97,28 @@ namespace Batch { return *this; } - Versatile & Versatile::operator , (const string & ch) throw(TypeMismatchException,ListIsFullException) + Versatile & Versatile::operator , (const string & ch) { *this += ch; return *this; } - Versatile & Versatile::operator = (const char * ch) throw(TypeMismatchException) + Versatile & Versatile::operator = (const char * ch) { return operator=(string(ch)); } - Versatile & Versatile::operator +=(const char * ch) throw(TypeMismatchException,ListIsFullException) + Versatile & Versatile::operator +=(const char * ch) { return operator+=(string(ch)); } - Versatile & Versatile::operator , (const char * ch) throw(TypeMismatchException,ListIsFullException) + Versatile & Versatile::operator , (const char * ch) { return operator,(string(ch)); } - Versatile & Versatile::operator = (const Couple & cp) throw(TypeMismatchException) + Versatile & Versatile::operator = (const Couple & cp) { checkType(COUPLE); eraseAll(); @@ -126,7 +126,7 @@ namespace Batch { return *this; } - Versatile & Versatile::operator +=(const Couple & cp) throw(TypeMismatchException,ListIsFullException) + Versatile & Versatile::operator +=(const Couple & cp) { checkType(COUPLE); // If max size is reached, throw a ListIsFullException @@ -140,7 +140,7 @@ namespace Batch { return *this; } - Versatile & Versatile::operator , (const Couple & cp) throw(TypeMismatchException,ListIsFullException) + Versatile & Versatile::operator , (const Couple & cp) { *this += cp; return *this; @@ -158,7 +158,7 @@ namespace Batch { return os; } - Versatile & Versatile::operator = (const int i) throw(TypeMismatchException) + Versatile & Versatile::operator = (const int i) { checkType(LONG); eraseAll(); @@ -166,7 +166,7 @@ namespace Batch { return *this; } - Versatile & Versatile::operator = (const bool b) throw(TypeMismatchException) + Versatile & Versatile::operator = (const bool b) { checkType(BOOL); eraseAll(); @@ -174,13 +174,13 @@ namespace Batch { return *this; } - void Versatile::checkType(DiscriminatorType t) const throw(TypeMismatchException) + void Versatile::checkType(DiscriminatorType t) const { if (_discriminator != t) throw (TypeMismatchException("Trying to change type of Versatile object \"" + _name + "\"")); } - Versatile::operator long() const throw(TypeMismatchException) + Versatile::operator long() const { // If the type does not correspond or if the list has more than one element, // throw a TypeMismatchException @@ -192,7 +192,7 @@ namespace Batch { return *( static_cast(this->front()) ); } - Versatile::operator bool() const throw(TypeMismatchException) + Versatile::operator bool() const { // If the type does not correspond or if the list has more than one element, // throw a TypeMismatchException @@ -204,12 +204,12 @@ namespace Batch { return *( static_cast(this->front()) ); } - Versatile::operator int() const throw(TypeMismatchException) + Versatile::operator int() const { return operator long(); } - Versatile::operator Couple() const throw(TypeMismatchException) + Versatile::operator Couple() const { // If the type does not correspond or if the list has more than one element, // throw a TypeMismatchException @@ -221,7 +221,7 @@ namespace Batch { return *( static_cast(this->front()) ); } - string Versatile::str() const throw(TypeMismatchException) + string Versatile::str() const { // If the type does not correspond, throw a TypeMismatchException if ( _discriminator != STRING || size() == 0 ) { @@ -240,7 +240,7 @@ namespace Batch { return s; } - Versatile::operator string () const throw(TypeMismatchException) + Versatile::operator string () const { return str(); } diff --git a/src/Core/Versatile.hxx b/src/Core/Versatile.hxx index b5747de..d72f8e9 100644 --- a/src/Core/Versatile.hxx +++ b/src/Core/Versatile.hxx @@ -65,32 +65,32 @@ namespace Batch { virtual ~Versatile(); // Affectation and concatenation operators from base types - Versatile & operator = (const long l) throw(TypeMismatchException); - Versatile & operator = (const std::string & ch) throw(TypeMismatchException); - Versatile & operator +=(const std::string & ch) throw(TypeMismatchException,ListIsFullException); - Versatile & operator , (const std::string & ch) throw(TypeMismatchException,ListIsFullException); - Versatile & operator = (const char * ch) throw(TypeMismatchException); - Versatile & operator +=(const char * ch) throw(TypeMismatchException,ListIsFullException); - Versatile & operator , (const char * ch) throw(TypeMismatchException,ListIsFullException); - Versatile & operator = (const Couple & cp) throw(TypeMismatchException); - Versatile & operator +=(const Couple & cp) throw(TypeMismatchException,ListIsFullException); - Versatile & operator , (const Couple & cp) throw(TypeMismatchException,ListIsFullException); - Versatile & operator = (const int i) throw(TypeMismatchException); - Versatile & operator = (const bool b) throw(TypeMismatchException); + Versatile & operator = (const long l); + Versatile & operator = (const std::string & ch); + Versatile & operator +=(const std::string & ch); + Versatile & operator , (const std::string & ch); + Versatile & operator = (const char * ch); + Versatile & operator +=(const char * ch); + Versatile & operator , (const char * ch); + Versatile & operator = (const Couple & cp); + Versatile & operator +=(const Couple & cp); + Versatile & operator , (const Couple & cp); + Versatile & operator = (const int i); + Versatile & operator = (const bool b); // Type conversion to base types - operator long() const throw(TypeMismatchException); - operator std::string() const throw(TypeMismatchException); - operator Couple() const throw(TypeMismatchException); - std::string str() const throw(TypeMismatchException); - operator bool() const throw(TypeMismatchException); - operator int() const throw(TypeMismatchException); + operator long() const; + operator std::string() const; + operator Couple() const; + std::string str() const; + operator bool() const; + operator int() const; // Display on a stream BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const Versatile & ); // Check the type - void checkType(DiscriminatorType t) const throw (TypeMismatchException); + void checkType(DiscriminatorType t) const; // Getter methods DiscriminatorType getType() const; diff --git a/src/OAR/BatchManager_OAR.cxx b/src/OAR/BatchManager_OAR.cxx index 03e74bc..1391b65 100644 --- a/src/OAR/BatchManager_OAR.cxx +++ b/src/OAR/BatchManager_OAR.cxx @@ -157,6 +157,7 @@ namespace Batch mem = params[MAXRAMSIZE]; if (params.find(QUEUE) != params.end()) queue = params[QUEUE].str(); + LIBBATCH_UNUSED(mem); string::size_type p1 = fileToExecute.find_last_of("/"); string::size_type p2 = fileToExecute.find_last_of("."); -- 2.39.2