summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-04-28 20:06:43 +0300
committerAndrei Karas <akaras@inbox.ru>2017-04-28 23:02:16 +0300
commit15919532c723ca0186b0c0c932cd1b90c7d2e570 (patch)
tree249673c7f5f06b2741826e12d7f69a9de379a52d
parent515323530ba1b93c8d5ba00b015bf55aa0ecb01c (diff)
downloadmanaverse-15919532c723ca0186b0c0c932cd1b90c7d2e570.tar.gz
manaverse-15919532c723ca0186b0c0c932cd1b90c7d2e570.tar.bz2
manaverse-15919532c723ca0186b0c0c932cd1b90c7d2e570.tar.xz
manaverse-15919532c723ca0186b0c0c932cd1b90c7d2e570.zip
Fix code style.
-rw-r--r--src/configuration_unittest.cc11
-rw-r--r--src/fs/virtfs/virtfs1_unittest.cc6
-rw-r--r--src/fs/virtfs/virtfsdir.cpp6
-rw-r--r--src/fs/virtfs/virtfsfuncs.h2
-rw-r--r--src/fs/virtfs/virtfszip.cpp8
-rw-r--r--src/resources/item/itemoption.h4
-rw-r--r--src/resources/item/itemoptionslist.h8
7 files changed, 27 insertions, 18 deletions
diff --git a/src/configuration_unittest.cc b/src/configuration_unittest.cc
index 66b454cd8..2e61c0669 100644
--- a/src/configuration_unittest.cc
+++ b/src/configuration_unittest.cc
@@ -36,11 +36,12 @@ namespace
class TestConfigListener : public ConfigListener
{
- void optionChanged(const std::string &name) override final
- {
- if (name == "testkey123")
- mCalled ++;
- }
+ public:
+ void optionChanged(const std::string &name) override final
+ {
+ if (name == "testkey123")
+ mCalled ++;
+ }
} testListener;
} // namespace
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index 1ddada282..a3b1b56cc 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -2105,9 +2105,9 @@ TEST_CASE("VirtFs1 getFilesWithDir2")
VirtFs::getFilesWithDir(pathJoin("evol", "icons"), list);
REQUIRE(list.size() == 3);
- REQUIRE(inList(list, pathJoin("evol" , "icons"), "evol-client.ico"));
- REQUIRE(inList(list, pathJoin("evol" , "icons"), "evol-client.png"));
- REQUIRE(inList(list, pathJoin("evol" , "icons"), "evol-client.xpm"));
+ REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.ico"));
+ REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.png"));
+ REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.xpm"));
VirtFs::unmountDir(prefix + "data");
}
diff --git a/src/fs/virtfs/virtfsdir.cpp b/src/fs/virtfs/virtfsdir.cpp
index 223b45e1d..902e686c0 100644
--- a/src/fs/virtfs/virtfsdir.cpp
+++ b/src/fs/virtfs/virtfsdir.cpp
@@ -485,13 +485,15 @@ namespace VirtFsDir
if (fstat(fd, &statbuf) == -1)
{
reportAlways("VirtFsDir::fileLength error.");
- return -1;
+ if (fd != FILEHDEFAULT)
+ FILECLOSE(fd);
+ return nullptr;
}
fileSize = static_cast<int>(statbuf.st_size);
#endif // USE_FILE_FOPEN
// Allocate memory and load the file
- char *restrict const buffer = new char[fileSize];
+ char *restrict const buffer = new char[CAST_SIZE(fileSize)];
if (fileSize > 0)
buffer[fileSize - 1] = 0;
diff --git a/src/fs/virtfs/virtfsfuncs.h b/src/fs/virtfs/virtfsfuncs.h
index 9f164c865..eb617ebd4 100644
--- a/src/fs/virtfs/virtfsfuncs.h
+++ b/src/fs/virtfs/virtfsfuncs.h
@@ -44,6 +44,8 @@ struct VirtFsFuncs final
getRealDir(nullptr),
enumerate(nullptr),
getFiles(nullptr),
+ getFilesWithDir(nullptr),
+ getDirs(nullptr),
isDirectory(nullptr),
openRead(nullptr),
openWrite(nullptr),
diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp
index 76ee69093..7d2f0e8b6 100644
--- a/src/fs/virtfs/virtfszip.cpp
+++ b/src/fs/virtfs/virtfszip.cpp
@@ -565,15 +565,15 @@ namespace VirtFsZip
reportAlways("VirtFsZip::read buffer is null");
return 0;
}
- const uint32_t pos = CAST_S32(file->mPos);
- const uint32_t sz = CAST_S32(file->mSize);
+ const size_t pos = file->mPos;
+ const size_t sz = file->mSize;
// if outside of buffer, return
if (pos >= sz)
return 0;
// pointer to start for buffer ready to read
const uint8_t *restrict const memPtr = file->mBuf + pos;
// left buffer size from pos to end
- const uint32_t memSize = sz - pos;
+ const uint32_t memSize = CAST_U32(sz - pos);
// number of objects possible to read
uint32_t memCount = memSize / objSize;
if (memCount == 0)
@@ -582,7 +582,7 @@ namespace VirtFsZip
if (memCount > objCount)
memCount = objCount;
// number of bytes to read from buffer
- const uint32_t memEnd = memCount * objSize;
+ const size_t memEnd = memCount * objSize;
memcpy(buffer, memPtr, memEnd);
file->mPos += memEnd;
return memCount;
diff --git a/src/resources/item/itemoption.h b/src/resources/item/itemoption.h
index 5d993c8d6..c4327622a 100644
--- a/src/resources/item/itemoption.h
+++ b/src/resources/item/itemoption.h
@@ -25,7 +25,9 @@
struct ItemOption final
{
- ItemOption()
+ ItemOption() :
+ index(0U),
+ value(0)
{ }
A_DELETE_COPY(ItemOption)
diff --git a/src/resources/item/itemoptionslist.h b/src/resources/item/itemoptionslist.h
index 7bb259028..725340f45 100644
--- a/src/resources/item/itemoptionslist.h
+++ b/src/resources/item/itemoptionslist.h
@@ -31,7 +31,8 @@
struct ItemOptionsList final
{
- explicit ItemOptionsList(const int amount0) :
+ explicit ItemOptionsList(const size_t amount0) :
+ options(nullptr),
amount(amount0),
pointer(0U)
{
@@ -39,6 +40,7 @@ struct ItemOptionsList final
}
ItemOptionsList() :
+ options(nullptr),
amount(maxItemOptions),
pointer(0U)
{
@@ -68,9 +70,9 @@ struct ItemOptionsList final
if (options0 == nullptr)
return nullptr;
- const int amount0 = options0->amount;
+ const size_t amount0 = options0->amount;
ItemOptionsList *const obj = new ItemOptionsList(amount0);
- for (int f = 0; f < amount0; f ++)
+ for (size_t f = 0; f < amount0; f ++)
{
obj->options[f].index = options0->options[f].index;
obj->options[f].value = options0->options[f].value;