summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-06 23:34:34 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-07 19:23:40 +0300
commit36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch)
tree190156cb88b13a38a6d13c69ee0742cc078065a1 /src/utils
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadmv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/base64.cpp16
-rw-r--r--src/utils/browserboxtools.cpp12
-rw-r--r--src/utils/chatutils.cpp20
-rw-r--r--src/utils/cpu.cpp24
-rw-r--r--src/utils/dumplibs.cpp2
-rw-r--r--src/utils/env.cpp4
-rw-r--r--src/utils/gmfunctions.cpp4
-rw-r--r--src/utils/langs.cpp8
-rw-r--r--src/utils/mutex.h4
-rw-r--r--src/utils/process.cpp12
-rw-r--r--src/utils/sdlhelper.cpp4
-rw-r--r--src/utils/sdlpixel.h4
-rw-r--r--src/utils/stringutils.cpp12
-rw-r--r--src/utils/translation/poparser.cpp4
-rw-r--r--src/utils/translation/translationmanager.cpp6
-rw-r--r--src/utils/xml/libxml.cpp28
-rw-r--r--src/utils/xmlutils.cpp6
17 files changed, 85 insertions, 85 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index b0828e99f..9f1c2a1d4 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -45,14 +45,14 @@ unsigned char *php3_base64_encode(const unsigned char *restrict const string,
int length,
int *restrict const ret_length)
{
- if (!string)
+ if (string == nullptr)
return nullptr;
const unsigned char *current = string;
int i = 0;
unsigned char *const result = static_cast<unsigned char *>(
calloc(CAST_SIZE((length + 3 - length % 3) * 4 / 3 + 1)
* sizeof(unsigned char), 1));
- if (!result)
+ if (result == nullptr)
return nullptr;
while (length > 2)
@@ -86,7 +86,7 @@ unsigned char *php3_base64_encode(const unsigned char *restrict const string,
result[i++] = base64_pad;
}
}
- if (ret_length)
+ if (ret_length != nullptr)
{
*ret_length = i;
}
@@ -105,7 +105,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
unsigned char *result = static_cast<unsigned char *>(
calloc(length + 1, 1));
- if (!result)
+ if (result == nullptr)
return nullptr;
/* run through the whole string, converting as we go */
@@ -124,7 +124,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
if (ch == ' ') ch = '+';
const char *const chp = strchr(base64_table, ch);
- if (!chp)
+ if (chp == nullptr)
continue;
ch = CAST_S32(chp - base64_table);
@@ -172,7 +172,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
break;
}
}
- if (ret_length)
+ if (ret_length != nullptr)
{
*ret_length = j;
}
@@ -187,7 +187,7 @@ std::string encodeBase64String(std::string value)
const_cast<char*>(value.c_str()));
unsigned char *const buf = php3_base64_encode(
str, CAST_S32(value.size()), &sz);
- if (!buf)
+ if (buf == nullptr)
return std::string();
value = std::string(reinterpret_cast<char*>(buf), sz);
@@ -203,7 +203,7 @@ std::string decodeBase64String(std::string value)
unsigned char *const buf = php3_base64_decode(
str, CAST_S32(value.size()), &sz);
- if (buf)
+ if (buf != nullptr)
value = std::string(reinterpret_cast<char*>(buf), sz);
else
value.clear();
diff --git a/src/utils/browserboxtools.cpp b/src/utils/browserboxtools.cpp
index 8a1fb42bb..5c7571c97 100644
--- a/src/utils/browserboxtools.cpp
+++ b/src/utils/browserboxtools.cpp
@@ -80,7 +80,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
const BeingTypeId id = static_cast<BeingTypeId>(
atoi(link.substr(1).c_str()));
BeingInfo *info = MonsterDB::get(id);
- if (info)
+ if (info != nullptr)
data = info->getName();
}
else if (!link.empty() && link[0] == 'p')
@@ -88,7 +88,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
const BeingTypeId id = static_cast<BeingTypeId>(
atoi(link.substr(1).c_str()));
BeingInfo *info = PETDB::get(id);
- if (info)
+ if (info != nullptr)
data = info->getName();
}
else if (!link.empty() && link[0] == 'h')
@@ -96,7 +96,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
const BeingTypeId id = static_cast<BeingTypeId>(
atoi(link.substr(1).c_str()));
BeingInfo *info = HomunculusDB::get(id);
- if (info)
+ if (info != nullptr)
data = info->getName();
}
else if (!link.empty() && link[0] == 'M')
@@ -104,7 +104,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
const BeingTypeId id = static_cast<BeingTypeId>(
atoi(link.substr(1).c_str()));
BeingInfo *info = MercenaryDB::get(id);
- if (info)
+ if (info != nullptr)
data = info->getName();
}
else if (!link.empty() && link[0] == 'q')
@@ -118,7 +118,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
if (idx != std::string::npos)
{
const int id = atoi(link.substr(0, idx).c_str());
- if (id)
+ if (id != 0)
{
std::vector<int> parts;
splitToIntVector(parts,
@@ -133,7 +133,7 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
else
{
const int id = atoi(link.c_str());
- if (id)
+ if (id != 0)
data = ItemDB::get(id).getName();
}
}
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp
index 456fc4233..53bb689a4 100644
--- a/src/utils/chatutils.cpp
+++ b/src/utils/chatutils.cpp
@@ -46,10 +46,10 @@ void outStringNormal(ChatTab *const tab,
const std::string &str,
const std::string &def)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
- if (!tab)
+ if (tab == nullptr)
{
chatHandler->talk(str, GENERAL_CHANNEL);
return;
@@ -65,7 +65,7 @@ void outStringNormal(ChatTab *const tab,
case ChatTabType::GUILD:
{
const Guild *const guild = localPlayer->getGuild();
- if (guild)
+ if (guild != nullptr)
{
#ifdef TMWA_SUPPORT
if (guild->getServerGuild())
@@ -74,7 +74,7 @@ void outStringNormal(ChatTab *const tab,
return;
guildHandler->chat(str);
}
- else if (guildManager)
+ else if (guildManager != nullptr)
{
guildManager->chat(str);
}
@@ -111,18 +111,18 @@ void outStringNormal(ChatTab *const tab,
void replaceVars(std::string &str)
{
- if (!localPlayer || !actorManager)
+ if ((localPlayer == nullptr) || (actorManager == nullptr))
return;
if (str.find("<PLAYER>") != std::string::npos)
{
const Being *target = localPlayer->getTarget();
- if (!target || target->getType() != ActorType::Player)
+ if ((target == nullptr) || target->getType() != ActorType::Player)
{
target = actorManager->findNearestLivingBeing(
localPlayer, 20, ActorType::Player, AllowSort_true);
}
- if (target)
+ if (target != nullptr)
replaceAll(str, "<PLAYER>", target->getName());
else
replaceAll(str, "<PLAYER>", "");
@@ -130,12 +130,12 @@ void replaceVars(std::string &str)
if (str.find("<MONSTER>") != std::string::npos)
{
const Being *target = localPlayer->getTarget();
- if (!target || target->getType() != ActorType::Monster)
+ if ((target == nullptr) || target->getType() != ActorType::Monster)
{
target = actorManager->findNearestLivingBeing(
localPlayer, 20, ActorType::Monster, AllowSort_true);
}
- if (target)
+ if (target != nullptr)
replaceAll(str, "<MONSTER>", target->getName());
else
replaceAll(str, "<MONSTER>", "");
@@ -167,7 +167,7 @@ void replaceVars(std::string &str)
std::string newStr;
const Party *party = nullptr;
if (localPlayer->isInParty() &&
- (party = localPlayer->getParty()))
+ ((party = localPlayer->getParty()) != nullptr))
{
party->getNames(names);
FOR_EACH (StringVectCIter, it, names)
diff --git a/src/utils/cpu.cpp b/src/utils/cpu.cpp
index 91f49f5a7..93353baf5 100644
--- a/src/utils/cpu.cpp
+++ b/src/utils/cpu.cpp
@@ -62,9 +62,9 @@ void Cpu::detect()
#elif defined(__linux__) || defined(__linux)
FILE *file = fopen("/proc/cpuinfo", "r");
char buf[1001];
- if (!file)
+ if (file == nullptr)
return;
- while (fgets(buf, 1000, file))
+ while (fgets(buf, 1000, file) != nullptr)
{
std::string str = buf;
if (findFirst(str, "flags"))
@@ -102,7 +102,7 @@ void Cpu::detect()
}
}
fclose(file);
- if (logger)
+ if (logger != nullptr)
logger->log("cpu features was not detected");
#else // OTHER
@@ -114,24 +114,24 @@ void Cpu::detect()
void Cpu::printFlags()
{
- if (!logger)
+ if (logger == nullptr)
return;
std::string str("CPU features:");
- if (mCpuFlags & FEATURE_MMX)
+ if ((mCpuFlags & FEATURE_MMX) != 0u)
str.append(" mmx");
- if (mCpuFlags & FEATURE_SSE)
+ if ((mCpuFlags & FEATURE_SSE) != 0u)
str.append(" sse");
- if (mCpuFlags & FEATURE_SSE2)
+ if ((mCpuFlags & FEATURE_SSE2) != 0u)
str.append(" sse2");
- if (mCpuFlags & FEATURE_SSSE3)
+ if ((mCpuFlags & FEATURE_SSSE3) != 0u)
str.append(" ssse3");
- if (mCpuFlags & FEATURE_SSE4)
+ if ((mCpuFlags & FEATURE_SSE4) != 0u)
str.append(" sse4");
- if (mCpuFlags & FEATURE_SSE42)
+ if ((mCpuFlags & FEATURE_SSE42) != 0u)
str.append(" sse4_2");
- if (mCpuFlags & FEATURE_AVX)
+ if ((mCpuFlags & FEATURE_AVX) != 0u)
str.append(" avx");
- if (mCpuFlags & FEATURE_AVX2)
+ if ((mCpuFlags & FEATURE_AVX2) != 0u)
str.append(" avx2");
logger->log(str);
}
diff --git a/src/utils/dumplibs.cpp b/src/utils/dumplibs.cpp
index 959337604..e08db3645 100644
--- a/src/utils/dumplibs.cpp
+++ b/src/utils/dumplibs.cpp
@@ -56,7 +56,7 @@ PRAGMACLANG6GCC(GCC diagnostic pop)
static void dumpLinkedSdlVersion(const char *const text,
const SDL_version *const version)
{
- if (version)
+ if (version != nullptr)
{
logger->log(" %s: %d.%d.%d",
text,
diff --git a/src/utils/env.cpp b/src/utils/env.cpp
index 1006806fb..364493500 100644
--- a/src/utils/env.cpp
+++ b/src/utils/env.cpp
@@ -65,14 +65,14 @@ void updateEnv()
void setEnv(const char *const name, const char *const value)
{
- if (!name || !value)
+ if ((name == nullptr) || (value == nullptr))
return;
#ifdef WIN32
if (putenv(const_cast<char*>((std::string(name)
+ "=" + value).c_str())))
#else // WIN32
- if (setenv(name, value, 1))
+ if (setenv(name, value, 1) != 0)
#endif // WIN32
{
logger->log("setenv failed: %s=%s", name, value);
diff --git a/src/utils/gmfunctions.cpp b/src/utils/gmfunctions.cpp
index 45179c02d..e6abc3e83 100644
--- a/src/utils/gmfunctions.cpp
+++ b/src/utils/gmfunctions.cpp
@@ -66,7 +66,7 @@ void runCharCommand(const std::string &command,
const std::string &name,
const std::string &params)
{
- if (localPlayer && name == localPlayer->getName())
+ if ((localPlayer != nullptr) && name == localPlayer->getName())
{
if (params.empty())
{
@@ -101,7 +101,7 @@ void runCharCommand(const std::string &command,
void runCharCommand(const std::string &command,
const std::string &name)
{
- if (localPlayer && name == localPlayer->getName())
+ if ((localPlayer != nullptr) && name == localPlayer->getName())
{
chatHandler->talk(std::string(
settings.gmCommandSymbol).append(
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
index 22cfaa474..595a7ea09 100644
--- a/src/utils/langs.cpp
+++ b/src/utils/langs.cpp
@@ -33,7 +33,7 @@
static const char *getLangName()
{
const char *const lang = getenv("LANG");
- if (lang && strlen(lang) > 1000)
+ if ((lang != nullptr) && strlen(lang) > 1000)
return nullptr;
return lang;
}
@@ -45,7 +45,7 @@ LangVect getLang()
if (lang.empty())
{
const char *const lng = getLangName();
- if (!lng)
+ if (lng == nullptr)
return langs;
lang = lng;
}
@@ -87,7 +87,7 @@ std::string getLangSimple()
if (lang.empty())
{
const char *const lng = getLangName();
- if (!lng)
+ if (lng == nullptr)
return "";
return lng;
}
@@ -104,7 +104,7 @@ std::string getLangShort()
if (lang.empty())
{
const char *const lng = getLangName();
- if (!lng)
+ if (lng == nullptr)
return "";
lang = lng;
}
diff --git a/src/utils/mutex.h b/src/utils/mutex.h
index 27adc5322..3703d20ab 100644
--- a/src/utils/mutex.h
+++ b/src/utils/mutex.h
@@ -97,13 +97,13 @@ inline void Mutex::unlock()
inline MutexLocker::MutexLocker(Mutex *const mutex) :
mMutex(mutex)
{
- if (mMutex)
+ if (mMutex != nullptr)
mMutex->lock();
}
inline MutexLocker::~MutexLocker()
{
- if (mMutex)
+ if (mMutex != nullptr)
mMutex->unlock();
}
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index f84506024..6431c22d5 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -117,21 +117,21 @@ int execFileWait(const std::string &pathName, const std::string &name,
pid_t mon_pid;
int status;
- if (!waitTime)
+ if (waitTime == 0)
waitTime = timeOut;
if ((mon_pid = fork()) == -1)
{ // fork error
return -1;
}
- else if (!mon_pid)
+ else if (mon_pid == 0)
{ // monitoring child
pid_t pid;
if ((pid = fork()) == -1)
{ // fork error
return -1;
}
- else if (!pid)
+ else if (pid == 0)
{ // work child
if (arg2.empty())
{
@@ -152,7 +152,7 @@ int execFileWait(const std::string &pathName, const std::string &name,
{ // fork error
return -1;
}
- else if (!sleep_pid)
+ else if (sleep_pid == 0)
{ // sleep pid
sleep(waitTime);
execl("/bin/true", "/bin/true", static_cast<char *>(nullptr));
@@ -191,7 +191,7 @@ bool execFile(const std::string &pathName, const std::string &name,
{
struct stat statbuf;
// file not exists
- if (stat(pathName.c_str(), &statbuf))
+ if (stat(pathName.c_str(), &statbuf) != 0)
return false;
pid_t pid;
@@ -199,7 +199,7 @@ bool execFile(const std::string &pathName, const std::string &name,
{ // fork error
return false;
}
- else if (!pid)
+ else if (pid == 0)
{ // work child
if (arg2.empty())
{
diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp
index c4d0b881b..261c09026 100644
--- a/src/utils/sdlhelper.cpp
+++ b/src/utils/sdlhelper.cpp
@@ -63,7 +63,7 @@ bool SDL::getAllVideoModes(StringVect &modeList)
}
else
{
- for (int i = 0; modes[i]; ++ i)
+ for (int i = 0; modes[i] != nullptr; ++ i)
{
const std::string modeString =
toString(CAST_S32(modes[i]->w)).append("x")
@@ -106,7 +106,7 @@ void SDL::setVsync(const int val)
bool SDL::getWindowWMInfo(const SDL_Surface *const window A_UNUSED,
SDL_SysWMinfo *const info)
{
- return SDL_GetWMInfo(info);
+ return SDL_GetWMInfo(info) != 0;
}
SDL_Thread *SDL::createThread(int (SDLCALL *fn)(void *),
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
index 432fa1939..455702757 100644
--- a/src/utils/sdlpixel.h
+++ b/src/utils/sdlpixel.h
@@ -82,7 +82,7 @@
inline void SDLputPixel(SDL_Surface* surface, int x, int y,
const Color& color)
{
- if (!surface)
+ if (surface == nullptr)
return;
const int bpp = surface->format->BytesPerPixel;
@@ -189,7 +189,7 @@ inline unsigned short SDLAlpha16(const unsigned short src,
inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
const Color& color)
{
- if (!surface)
+ if (surface == nullptr)
return;
const int bpp = surface->format->BytesPerPixel;
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 90d5835a5..0dfd3b597 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -75,7 +75,7 @@ std::string &toUpper(std::string &str)
unsigned int atox(const std::string &str)
{
unsigned int value = 0;
- if (sscanf(str.c_str(), "0x%06x", &value))
+ if (sscanf(str.c_str(), "0x%06x", &value) != 0)
return value;
return 0;
}
@@ -139,7 +139,7 @@ int compareStrI(const std::string &a, const std::string &b)
for (; itA < endA && itB < endB; ++itA, ++itB)
{
const int comp = tolower(*itA) - tolower(*itB);
- if (comp)
+ if (comp != 0)
return comp;
}
@@ -240,7 +240,7 @@ const std::string encodeStr(unsigned int value, const unsigned int size)
buf += CAST_S8(value % base + start);
value /= base;
}
- while (value);
+ while (value != 0u);
while (buf.length() < size)
buf += CAST_S8(start);
@@ -320,7 +320,7 @@ const char* getSafeUtf8String(const std::string &text)
void getSafeUtf8String(std::string text, char *const buf)
{
- if (!buf)
+ if (buf == nullptr)
return;
const size_t sz = text.size();
const size_t size = sz + UTF8_MAX_SIZE;
@@ -633,7 +633,7 @@ std::string stringToHexPath(const std::string &str)
void deleteCharLeft(std::string &str,
unsigned *const pos)
{
- if (!pos)
+ if (pos == nullptr)
return;
while (*pos > 0)
@@ -956,7 +956,7 @@ std::string timeToStr(const uint32_t time)
char buf[101];
const time_t tempTime = time;
tm *const timeInfo = localtime(&tempTime);
- if (strftime(&buf[0], 100, "%Y-%m-%d_%H-%M-%S", timeInfo))
+ if (strftime(&buf[0], 100, "%Y-%m-%d_%H-%M-%S", timeInfo) != 0u)
return std::string(buf);
else
return "unknown";
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
index 8244fd627..1050cc82e 100644
--- a/src/utils/translation/poparser.cpp
+++ b/src/utils/translation/poparser.cpp
@@ -48,7 +48,7 @@ void PoParser::openFile(const std::string &name)
int size;
const char *buf = VirtFs::loadFile(getFileName(name), size);
- if (buf)
+ if (buf != nullptr)
{
mFile.str(std::string(buf, size));
delete [] buf;
@@ -66,7 +66,7 @@ PoDict *PoParser::load(const std::string &restrict lang,
logger->log("loading lang: %s, file: %s", lang.c_str(), fileName.c_str());
setLang(lang);
- if (!dict)
+ if (dict == nullptr)
mDict = getDict();
else
mDict = dict;
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 67527b06a..aa0dd47da 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -90,7 +90,7 @@ PoDict *TranslationManager::loadLang(const LangVect &lang,
if (!name.empty())
return parser.load(name, subName + name, dict);
logger->log("can't find client data translation");
- if (dict)
+ if (dict != nullptr)
return dict;
return PoParser::getEmptyDict();
}
@@ -99,14 +99,14 @@ bool TranslationManager::translateFile(const std::string &fileName,
PoDict *const dict,
StringVect &lines)
{
- if (!dict || fileName.empty())
+ if ((dict == nullptr) || fileName.empty())
return false;
int contentsLength;
const char *fileContents = VirtFs::loadFile(fileName,
contentsLength);
- if (!fileContents)
+ if (fileContents == nullptr)
{
logger->log("Couldn't load file: %s", fileName.c_str());
return false;
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
index 32e0cc556..840c28edd 100644
--- a/src/utils/xml/libxml.cpp
+++ b/src/utils/xml/libxml.cpp
@@ -51,7 +51,7 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
{
- if (!msg)
+ if (msg == nullptr)
return;
size_t size = 1024;
@@ -68,7 +68,7 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
buf[size] = 0;
va_end(ap);
- if (logger)
+ if (logger != nullptr)
logger->log_r("%s", buf);
else
puts(buf);
@@ -131,12 +131,12 @@ namespace XML
}
}
- if (data)
+ if (data != nullptr)
{
mDoc = xmlParseMemory(data, size);
delete [] data;
- if (!mDoc)
+ if (mDoc == nullptr)
{
reportAlways("Error parsing XML file %s", filename.c_str());
}
@@ -150,20 +150,20 @@ namespace XML
}
Document::Document(const char *const data, const int size) :
- mDoc(data ? xmlParseMemory(data, size) : nullptr),
+ mDoc(data != nullptr ? xmlParseMemory(data, size) : nullptr),
mIsValid(true)
{
}
Document::~Document()
{
- if (mDoc)
+ if (mDoc != nullptr)
xmlFreeDoc(mDoc);
}
XmlNodePtr Document::rootNode()
{
- return mDoc ? xmlDocGetRootElement(mDoc) : nullptr;
+ return mDoc != nullptr ? xmlDocGetRootElement(mDoc) : nullptr;
}
int getProperty(XmlNodeConstPtr node,
@@ -173,7 +173,7 @@ namespace XML
int &ret = def;
xmlChar *const prop = XmlGetProp(node, name);
- if (prop)
+ if (prop != nullptr)
{
ret = atoi(reinterpret_cast<const char*>(prop));
xmlFree(prop);
@@ -191,7 +191,7 @@ namespace XML
int &ret = def;
xmlChar *const prop = XmlGetProp(node, name);
- if (prop)
+ if (prop != nullptr)
{
ret = atoi(reinterpret_cast<char*>(prop));
xmlFree(prop);
@@ -210,7 +210,7 @@ namespace XML
double &ret = def;
xmlChar *const prop = XmlGetProp(node, name);
- if (prop)
+ if (prop != nullptr)
{
ret = atof(reinterpret_cast<char*>(prop));
xmlFree(prop);
@@ -224,7 +224,7 @@ namespace XML
const std::string &def)
{
xmlChar *const prop = XmlGetProp(node, name);
- if (prop)
+ if (prop != nullptr)
{
std::string val = reinterpret_cast<char*>(prop);
xmlFree(prop);
@@ -239,7 +239,7 @@ namespace XML
const std::string &def)
{
std::string str = getProperty(node, name, def);
- if (!translator)
+ if (translator == nullptr)
return str;
return translator->getStr(str);
@@ -268,7 +268,7 @@ namespace XML
XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
const char *const name)
{
- if (!parent)
+ if (parent == nullptr)
return nullptr;
for_each_xml_child_node(child, parent)
{
@@ -300,7 +300,7 @@ namespace XML
{
const xmlDocPtr doc = xmlReadFile(fileName.c_str(),
nullptr, XML_PARSE_PEDANTIC);
- const bool valid1(doc);
+ const bool valid1(doc != nullptr);
xmlFreeDoc(doc);
if (!valid1)
return false;
diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp
index a6648c212..ccb3aa870 100644
--- a/src/utils/xmlutils.cpp
+++ b/src/utils/xmlutils.cpp
@@ -37,7 +37,7 @@ void readXmlIntVector(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str()))
+ if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
{
logger->log("Error while loading %s!", fileName.c_str());
return;
@@ -88,7 +88,7 @@ void readXmlStringMap(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str()))
+ if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
{
logger->log("Error while loading %s!", fileName.c_str());
return;
@@ -142,7 +142,7 @@ void readXmlIntMap(const std::string &fileName,
XML::Document doc(fileName, UseVirtFs_true, skipError);
XmlNodeConstPtrConst rootNode = doc.rootNode();
- if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str()))
+ if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
{
logger->log("Error while loading %s!", fileName.c_str());
return;