summaryrefslogtreecommitdiff
path: root/src/fs
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/fs
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/fs')
-rw-r--r--src/fs/files.cpp12
-rw-r--r--src/fs/mkdir.cpp8
-rw-r--r--src/fs/paths.cpp2
-rw-r--r--src/fs/virtfs/fsdir.cpp18
-rw-r--r--src/fs/virtfs/fsdirrwops.cpp8
-rw-r--r--src/fs/virtfs/fszip.cpp2
-rw-r--r--src/fs/virtfs/fsziprwops.cpp6
-rw-r--r--src/fs/virtfs/rwops.cpp4
-rw-r--r--src/fs/virtfs/tools.cpp8
9 files changed, 34 insertions, 34 deletions
diff --git a/src/fs/files.cpp b/src/fs/files.cpp
index 9d7bfd125..d1f36cbdc 100644
--- a/src/fs/files.cpp
+++ b/src/fs/files.cpp
@@ -183,7 +183,7 @@ int Files::copyFile(const std::string &restrict srcName,
const int chunkSize = 512000;
char *buf = new char[chunkSize];
size_t sz = 0;
- while ((sz = fread(buf, 1, chunkSize, srcFile)))
+ while ((sz = fread(buf, 1, chunkSize, srcFile)) != 0u)
{
if (fwrite(buf, 1, sz, dstFile) != sz)
{
@@ -245,7 +245,7 @@ void Files::saveTextFile(const std::string &path,
const std::string &restrict name,
const std::string &restrict text)
{
- if (!mkdir_r(path.c_str()))
+ if (mkdir_r(path.c_str()) == 0)
{
std::ofstream file;
std::string fileName = pathJoin(path, name);
@@ -269,9 +269,9 @@ void Files::deleteFilesInDirectory(std::string path)
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
const std::string file = next_file->d_name;
if (file != "." && file != "..")
@@ -289,10 +289,10 @@ void Files::enumFiles(StringVect &files,
path += dirSeparator;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
const struct dirent *next_file = nullptr;
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
const std::string file = next_file->d_name;
if (file == "." || file == "..")
diff --git a/src/fs/mkdir.cpp b/src/fs/mkdir.cpp
index e84ab5f28..d45810b7c 100644
--- a/src/fs/mkdir.cpp
+++ b/src/fs/mkdir.cpp
@@ -105,7 +105,7 @@ int mkdir_r(const char *const pathname)
/// Create a directory, making leading components first if necessary
int mkdir_r(const char *const pathname)
{
- if (!pathname)
+ if (pathname == nullptr)
return -1;
const size_t len = CAST_SIZE(strlen(pathname));
@@ -121,7 +121,7 @@ int mkdir_r(const char *const pathname)
tmp[len + 1] = '\0';
}
- for (p = tmp; *p; p++)
+ for (p = tmp; *p != 0; p++)
{
if (*p == '/')
{
@@ -135,7 +135,7 @@ int mkdir_r(const char *const pathname)
// check if the name already exists, but not as directory
struct stat statbuf;
- if (!stat(tmp, &statbuf))
+ if (stat(tmp, &statbuf) == 0)
{
if (S_ISDIR(statbuf.st_mode))
{
@@ -149,7 +149,7 @@ int mkdir_r(const char *const pathname)
}
}
- if (mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
+ if (mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
{
delete []tmp;
return -1;
diff --git a/src/fs/paths.cpp b/src/fs/paths.cpp
index 418e2fcf7..a0165fc43 100644
--- a/src/fs/paths.cpp
+++ b/src/fs/paths.cpp
@@ -79,7 +79,7 @@ std::string getRealPath(const std::string &str)
// defined(__native_client__)
char *realPath = realpath(str.c_str(), nullptr);
- if (!realPath)
+ if (realPath == nullptr)
return "";
#endif // defined(__OpenBSD__) || defined(__ANDROID__) ||
// defined(__native_client__)
diff --git a/src/fs/virtfs/fsdir.cpp b/src/fs/virtfs/fsdir.cpp
index c3b0d3c66..bc73771e7 100644
--- a/src/fs/virtfs/fsdir.cpp
+++ b/src/fs/virtfs/fsdir.cpp
@@ -198,9 +198,9 @@ namespace FsDir
dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
const std::string file = next_file->d_name;
if (file == "." || file == "..")
@@ -457,7 +457,7 @@ namespace FsDir
}
const int64_t len = static_cast<int64_t>(statbuf.st_size);
#endif // USE_FILE_FOPEN
- return pos < 0 || len < 0 || pos >= len;
+ return static_cast<int>(pos < 0 || len < 0 || pos >= len);
}
const char *loadFile(FsEntry *restrict const entry,
@@ -531,9 +531,9 @@ namespace FsDir
dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
struct stat statbuf;
const std::string file = next_file->d_name;
@@ -581,9 +581,9 @@ namespace FsDir
dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
struct stat statbuf;
const std::string file = next_file->d_name;
@@ -631,9 +631,9 @@ namespace FsDir
dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
- if (dir)
+ if (dir != nullptr)
{
- while ((next_file = readdir(dir)))
+ while ((next_file = readdir(dir)) != nullptr)
{
struct stat statbuf;
const std::string file = next_file->d_name;
diff --git a/src/fs/virtfs/fsdirrwops.cpp b/src/fs/virtfs/fsdirrwops.cpp
index d0f9a3e6d..e77a4fc5f 100644
--- a/src/fs/virtfs/fsdirrwops.cpp
+++ b/src/fs/virtfs/fsdirrwops.cpp
@@ -37,7 +37,7 @@ namespace FsDir
const RWOPSINT offset,
const int whence)
{
- if (!rw)
+ if (rw == nullptr)
return -1;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -149,7 +149,7 @@ namespace FsDir
const RWOPSSIZE size,
const RWOPSSIZE maxnum)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -185,7 +185,7 @@ namespace FsDir
const RWOPSSIZE size,
const RWOPSSIZE maxnum)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -218,7 +218,7 @@ namespace FsDir
int rwops_close(SDL_RWops *const rw)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File*>(
rw->hidden.unknown.data1);
diff --git a/src/fs/virtfs/fszip.cpp b/src/fs/virtfs/fszip.cpp
index d70df7749..43891c783 100644
--- a/src/fs/virtfs/fszip.cpp
+++ b/src/fs/virtfs/fszip.cpp
@@ -666,7 +666,7 @@ namespace FsZip
if (file == nullptr)
return -1;
- return file->mPos >= file->mSize;
+ return static_cast<int>(file->mPos >= file->mSize);
}
const char *loadFile(FsEntry *restrict const entry,
diff --git a/src/fs/virtfs/fsziprwops.cpp b/src/fs/virtfs/fsziprwops.cpp
index efe1c3670..739ad4d3a 100644
--- a/src/fs/virtfs/fsziprwops.cpp
+++ b/src/fs/virtfs/fsziprwops.cpp
@@ -38,7 +38,7 @@ namespace FsZip
const RWOPSINT offset,
const int whence)
{
- if (!rw)
+ if (rw == nullptr)
return -1;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -108,7 +108,7 @@ namespace FsZip
const RWOPSSIZE size,
const RWOPSSIZE maxnum)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File *>(
rw->hidden.unknown.data1);
@@ -130,7 +130,7 @@ namespace FsZip
int rwops_close(SDL_RWops *const rw)
{
- if (!rw)
+ if (rw == nullptr)
return 0;
File *const handle = static_cast<File*>(
rw->hidden.unknown.data1);
diff --git a/src/fs/virtfs/rwops.cpp b/src/fs/virtfs/rwops.cpp
index 3a18d53c2..e6ff601b3 100644
--- a/src/fs/virtfs/rwops.cpp
+++ b/src/fs/virtfs/rwops.cpp
@@ -63,14 +63,14 @@ SDL_RWops *create_rwops(File *const file)
{
SDL_RWops *retval = nullptr;
- if (!file)
+ if (file == nullptr)
{
logger->assertLog("VirtFs::rwops_seek: create rwops error.");
}
else
{
retval = SDL_AllocRW();
- if (retval)
+ if (retval != nullptr)
{
#ifdef USE_SDL2
retval->size = file->funcs->rwops_size;
diff --git a/src/fs/virtfs/tools.cpp b/src/fs/virtfs/tools.cpp
index a5bf06097..7850d056b 100644
--- a/src/fs/virtfs/tools.cpp
+++ b/src/fs/virtfs/tools.cpp
@@ -47,7 +47,7 @@ namespace VirtFs
const size_t len = str.size();
if (len > ext.length() &&
- !ext.compare(str.substr(len - ext.length())))
+ (ext.compare(str.substr(len - ext.length())) == 0))
{
const std::string file = path + str;
const std::string realPath = VirtFs::getRealDir(file);
@@ -66,7 +66,7 @@ namespace VirtFs
const std::string str = *i;
const size_t len = str.size();
if (len > ext.length() &&
- !ext.compare(str.substr(len - ext.length())))
+ (ext.compare(str.substr(len - ext.length())) == 0))
{
const std::string file = path + str;
const std::string realPath = VirtFs::getRealDir(file);
@@ -122,7 +122,7 @@ namespace VirtFs
int contentsLength;
const char *fileContents = VirtFs::loadFile(fileName, contentsLength);
- if (!fileContents)
+ if (fileContents == nullptr)
{
logger->log("Couldn't load text file: %s", fileName.c_str());
return std::string();
@@ -138,7 +138,7 @@ namespace VirtFs
int contentsLength;
const char *fileContents = VirtFs::loadFile(fileName, contentsLength);
- if (!fileContents)
+ if (fileContents == nullptr)
{
logger->log("Couldn't load text file: %s", fileName.c_str());
return false;