summaryrefslogtreecommitdiff
path: root/src/fs/virtfs
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-11 21:39:42 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-11 21:39:42 +0300
commita721e4898f71a68ecb916940864599d462880e5b (patch)
tree50442e8b86707221f498ea0f304a5314a0e67430 /src/fs/virtfs
parent81b97b30afa0c72e5ff17162c7d1fa88dd6187fb (diff)
downloadmv-a721e4898f71a68ecb916940864599d462880e5b.tar.gz
mv-a721e4898f71a68ecb916940864599d462880e5b.tar.bz2
mv-a721e4898f71a68ecb916940864599d462880e5b.tar.xz
mv-a721e4898f71a68ecb916940864599d462880e5b.zip
Fix different issues found by automatic checks.
Diffstat (limited to 'src/fs/virtfs')
-rw-r--r--src/fs/virtfs/fileapi.h2
-rw-r--r--src/fs/virtfs/virtfileprivate.cpp4
-rw-r--r--src/fs/virtfs/virtfs.cpp6
-rw-r--r--src/fs/virtfs/virtfs_unittest.cc6
-rw-r--r--src/fs/virtfs/virtfsdir.cpp3
-rw-r--r--src/fs/virtfs/virtfsdir.h3
-rw-r--r--src/fs/virtfs/virtfszip.cpp5
-rw-r--r--src/fs/virtfs/virtfszip.h3
-rw-r--r--src/fs/virtfs/virtzipentry.cpp3
-rw-r--r--src/fs/virtfs/zip.cpp2
-rw-r--r--src/fs/virtfs/zip.h1
-rw-r--r--src/fs/virtfs/ziplocalheader.cpp2
12 files changed, 10 insertions, 30 deletions
diff --git a/src/fs/virtfs/fileapi.h b/src/fs/virtfs/fileapi.h
index 7654e06d4..121506816 100644
--- a/src/fs/virtfs/fileapi.h
+++ b/src/fs/virtfs/fileapi.h
@@ -22,6 +22,8 @@
#define UTILS_VIRTFS_FILEAPI_H
#ifndef USE_PHYSFS
+#include "localconsts.h"
+
#ifdef USE_FILE_FOPEN
#define FILEHTYPE FILE *const
#define FILEMTYPE char *
diff --git a/src/fs/virtfs/virtfileprivate.cpp b/src/fs/virtfs/virtfileprivate.cpp
index 682992c68..5baadbc15 100644
--- a/src/fs/virtfs/virtfileprivate.cpp
+++ b/src/fs/virtfs/virtfileprivate.cpp
@@ -22,7 +22,6 @@
#include "fs/virtfs/virtfileprivate.h"
#include <unistd.h>
-#include <zlib.h>
#include "debug.h"
@@ -55,7 +54,6 @@ VirtFilePrivate::~VirtFilePrivate()
{
if (mFd != FILEHDEFAULT)
FILECLOSE(mFd);
- if (mBuf)
- delete [] mBuf;
+ delete [] mBuf;
}
#endif // USE_PHYSFS
diff --git a/src/fs/virtfs/virtfs.cpp b/src/fs/virtfs/virtfs.cpp
index 9cc36fda8..dd305303a 100644
--- a/src/fs/virtfs/virtfs.cpp
+++ b/src/fs/virtfs/virtfs.cpp
@@ -36,7 +36,6 @@
#include "fs/virtfs/zip.h"
#include "utils/checkutils.h"
-#include "utils/dtor.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -107,7 +106,7 @@ namespace VirtFs
{
FOR_EACH (std::vector<VirtFsEntry*>::const_iterator, it, mEntries)
{
- VirtFsEntry *const entry = *it;
+ const VirtFsEntry *const entry = *it;
if (entry->root == root &&
entry->type == type)
{
@@ -282,7 +281,7 @@ namespace VirtFs
std::string rootDir = newDir;
if (findLast(rootDir, std::string(dirSeparator)) == false)
rootDir += dirSeparator;
- VirtFsEntry *const entry = searchEntryByRootInternal(rootDir);
+ const VirtFsEntry *const entry = searchEntryByRootInternal(rootDir);
if (entry != nullptr)
{
reportAlways("VirtFs::addToSearchPath already exists: %s",
@@ -506,7 +505,6 @@ namespace VirtFs
else
delete entry;
}
-// delete_all(mEntries);
mEntries.clear();
return true;
}
diff --git a/src/fs/virtfs/virtfs_unittest.cc b/src/fs/virtfs/virtfs_unittest.cc
index bf040d707..66a9c6435 100644
--- a/src/fs/virtfs/virtfs_unittest.cc
+++ b/src/fs/virtfs/virtfs_unittest.cc
@@ -192,7 +192,6 @@ TEST_CASE("VirtFs1 mountZip")
std::string name("data/test/test.zip");
std::string prefix;
const std::string sep = dirSeparator;
- std::vector<ZipLocalHeader*> headers;
if (Files::existsLocal(name) == false)
prefix = "../";
@@ -311,7 +310,6 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
std::string name("data/test/test.zip");
std::string prefix;
const std::string sep = dirSeparator;
- std::vector<ZipLocalHeader*> headers;
if (Files::existsLocal(name) == false)
prefix = "../";
@@ -676,7 +674,7 @@ TEST_CASE("VirtFs1 getRealDir2")
delete2(logger);
}
-static bool inList(VirtList *list,
+static bool inList(const VirtList *const list,
const std::string &name)
{
FOR_EACH (StringVectCIter, it, list->names)
@@ -745,7 +743,6 @@ TEST_CASE("VirtFs1 enumerateFiles2")
VirtList *list = nullptr;
list = VirtFs::enumerateFiles("/");
- const size_t sz = list->names.size();
REQUIRE(list->names.size() == 5);
REQUIRE(inList(list, "file1.txt"));
REQUIRE_FALSE(inList(list, "file2.txt"));
@@ -772,7 +769,6 @@ TEST_CASE("VirtFs1 enumerateFiles3")
list = VirtFs::enumerateFiles("/");
const size_t sz = list->names.size();
- REQUIRE(list->names.size() == 6);
REQUIRE(inList(list, "file1.txt"));
REQUIRE(inList(list, "file2.txt"));
VirtFs::freeList(list);
diff --git a/src/fs/virtfs/virtfsdir.cpp b/src/fs/virtfs/virtfsdir.cpp
index ba320ae2e..69e8fd25a 100644
--- a/src/fs/virtfs/virtfsdir.cpp
+++ b/src/fs/virtfs/virtfsdir.cpp
@@ -25,7 +25,6 @@
#include "fs/files.h"
#include "fs/mkdir.h"
#include "fs/paths.h"
-#include "fs/virtfs.h"
#include "fs/virtfile.h"
#include "fs/virtfsfuncs.h"
#include "fs/virtlist.h"
@@ -34,7 +33,6 @@
#include "fs/virtfs/virtfileprivate.h"
#include "utils/checkutils.h"
-#include "utils/dtor.h"
#include "utils/stringutils.h"
#include <dirent.h>
@@ -167,7 +165,6 @@ namespace VirtFsDir
std::string &realDir)
{
VirtDirEntry *const dirEntry = static_cast<VirtDirEntry*>(entry);
- const std::string path = dirEntry->root + filename;
if (Files::existsLocal(dirEntry->root + filename))
{
realDir = dirEntry->userDir;
diff --git a/src/fs/virtfs/virtfsdir.h b/src/fs/virtfs/virtfsdir.h
index e689fcd95..b292bd71d 100644
--- a/src/fs/virtfs/virtfsdir.h
+++ b/src/fs/virtfs/virtfsdir.h
@@ -22,9 +22,6 @@
#define UTILS_VIRTFSDIR_H
#ifndef USE_PHYSFS
-#include "enums/simpletypes/append.h"
-#include "enums/simpletypes/skiperror.h"
-
#include "fs/virtfs/fileapi.h"
#include "utils/stringvector.h"
diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp
index 0f1021793..e085ac307 100644
--- a/src/fs/virtfs/virtfszip.cpp
+++ b/src/fs/virtfs/virtfszip.cpp
@@ -22,8 +22,6 @@
#include "fs/virtfs/virtfszip.h"
-#include "fs/files.h"
-#include "fs/paths.h"
#include "fs/virtfsfuncs.h"
#include "fs/virtfile.h"
#include "fs/virtlist.h"
@@ -34,7 +32,6 @@
#include "fs/virtfs/ziplocalheader.h"
#include "utils/checkutils.h"
-#include "utils/dtor.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -222,7 +219,7 @@ namespace VirtFsZip
it2,
zipEntry->mHeaders)
{
- ZipLocalHeader *restrict const header = *it2;
+ const ZipLocalHeader *restrict const header = *it2;
if (header->fileName == filename)
{
uint8_t *restrict const buf = Zip::readFile(header);
diff --git a/src/fs/virtfs/virtfszip.h b/src/fs/virtfs/virtfszip.h
index bf4f5b3be..f615e38fd 100644
--- a/src/fs/virtfs/virtfszip.h
+++ b/src/fs/virtfs/virtfszip.h
@@ -22,9 +22,6 @@
#define UTILS_VIRTFSZIP_H
#ifndef USE_PHYSFS
-#include "enums/simpletypes/append.h"
-#include "enums/simpletypes/skiperror.h"
-
#include "utils/stringvector.h"
#include "localconsts.h"
diff --git a/src/fs/virtfs/virtzipentry.cpp b/src/fs/virtfs/virtzipentry.cpp
index 324e54fb4..216603bed 100644
--- a/src/fs/virtfs/virtzipentry.cpp
+++ b/src/fs/virtfs/virtzipentry.cpp
@@ -31,7 +31,8 @@
VirtZipEntry::VirtZipEntry(const std::string &restrict archiveName,
VirtFsFuncs *restrict const funcs0) :
VirtFsEntry(FsEntryType::Zip, funcs0),
- mHeaders()
+ mHeaders(),
+ mDirs()
{
root = archiveName;
}
diff --git a/src/fs/virtfs/zip.cpp b/src/fs/virtfs/zip.cpp
index 5ce90069e..d7bb095c3 100644
--- a/src/fs/virtfs/zip.cpp
+++ b/src/fs/virtfs/zip.cpp
@@ -89,7 +89,6 @@ namespace Zip
archiveName.c_str());
return false;
}
- size_t cnt = 0U;
uint8_t *const buf = new uint8_t[65535 + 10];
uint16_t val16 = 0U;
uint16_t method = 0U;
@@ -102,6 +101,7 @@ namespace Zip
// format source https://en.wikipedia.org/wiki/Zip_%28file_format%29
while (feof(arcFile) == 0)
{
+ size_t cnt = 0U;
// file header pointer on 0
// read file header signature
readVal(buf, 4, "zip file header"); // + 4
diff --git a/src/fs/virtfs/zip.h b/src/fs/virtfs/zip.h
index ddb5d7508..8efbd05e4 100644
--- a/src/fs/virtfs/zip.h
+++ b/src/fs/virtfs/zip.h
@@ -25,7 +25,6 @@
#include "localconsts.h"
#include <string>
-#include <vector>
struct VirtZipEntry;
struct ZipLocalHeader;
diff --git a/src/fs/virtfs/ziplocalheader.cpp b/src/fs/virtfs/ziplocalheader.cpp
index eb8ba3e78..36224aa68 100644
--- a/src/fs/virtfs/ziplocalheader.cpp
+++ b/src/fs/virtfs/ziplocalheader.cpp
@@ -26,8 +26,6 @@
#include "localconsts.h"
-#include <string>
-
#include "debug.h"
ZipLocalHeader::ZipLocalHeader() :