Merge pull request #1147 from SaberUK/insp20+gcc6

[2.0] Fix GCC 6 warning about null checking this.
This commit is contained in:
Attila Molnar 2016-02-29 12:40:21 +01:00
commit ccd4c11ea1

View File

@ -388,19 +388,20 @@ bool ParseStack::ParseExec(const std::string& name, int flags, const std::string
return ok; return ok;
} }
bool ConfigTag::readString(const std::string& key, std::string& value, bool allow_lf)
{
#ifdef __clang__ #ifdef __clang__
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wundefined-bool-conversion" # pragma clang diagnostic ignored "-Wundefined-bool-conversion"
#elif defined __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpragmas"
# pragma GCC diagnostic ignored "-Wnonnull-compare"
#endif #endif
bool ConfigTag::readString(const std::string& key, std::string& value, bool allow_lf)
{
// TODO: this is undefined behaviour but changing the API is too risky for 2.0. // TODO: this is undefined behaviour but changing the API is too risky for 2.0.
if (!this) if (!this)
return false; return false;
#ifdef __clang__
# pragma clang diagnostic pop
#endif
for(std::vector<KeyVal>::iterator j = items.begin(); j != items.end(); ++j) for(std::vector<KeyVal>::iterator j = items.begin(); j != items.end(); ++j)
{ {
if(j->first != key) if(j->first != key)
@ -418,6 +419,11 @@ bool ConfigTag::readString(const std::string& key, std::string& value, bool allo
} }
return false; return false;
} }
#ifdef __clang__
# pragma clang diagnostic pop
#elif defined __GNUC__
# pragma GCC diagnostic pop
#endif
std::string ConfigTag::getString(const std::string& key, const std::string& def) std::string ConfigTag::getString(const std::string& key, const std::string& def)
{ {