diff --git a/encfs/BlockNameIO.cpp b/encfs/BlockNameIO.cpp index 0fdff9a..89f96c2 100644 --- a/encfs/BlockNameIO.cpp +++ b/encfs/BlockNameIO.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "Cipher.h" #include "CipherKey.h" @@ -94,20 +95,19 @@ Interface BlockNameIO::CurrentInterface(bool caseInsensitive) { return Interface("nameio/block", 4, 0, 2); } -BlockNameIO::BlockNameIO(const Interface &iface, - const std::shared_ptr &cipher, - const CipherKey &key, int blockSize, +BlockNameIO::BlockNameIO(const Interface &iface, std::shared_ptr cipher, + CipherKey key, int blockSize, bool caseInsensitiveEncoding) : _interface(iface.current()), _bs(blockSize), - _cipher(cipher), - _key(key), + _cipher(std::move(cipher)), + _key(std::move(key)), _caseInsensitive(caseInsensitiveEncoding) { // just to be safe.. rAssert(blockSize < 128); } -BlockNameIO::~BlockNameIO() {} +BlockNameIO::~BlockNameIO() = default; Interface BlockNameIO::interface() const { return CurrentInterface(_caseInsensitive); diff --git a/encfs/BlockNameIO.h b/encfs/BlockNameIO.h index 4ea0594..653159f 100644 --- a/encfs/BlockNameIO.h +++ b/encfs/BlockNameIO.h @@ -41,8 +41,8 @@ class BlockNameIO : public NameIO { public: static Interface CurrentInterface(bool caseInsensitive = false); - BlockNameIO(const Interface &iface, const std::shared_ptr &cipher, - const CipherKey &key, int blockSize, + BlockNameIO(const Interface &iface, std::shared_ptr cipher, + CipherKey key, int blockSize, bool caseInsensitiveEncoding = false); virtual ~BlockNameIO(); diff --git a/encfs/Cipher.cpp b/encfs/Cipher.cpp index 00b9a8d..50422d9 100644 --- a/encfs/Cipher.cpp +++ b/encfs/Cipher.cpp @@ -148,9 +148,9 @@ std::shared_ptr Cipher::New(const Interface &iface, int keyLen) { return result; } -Cipher::Cipher() {} +Cipher::Cipher() = default; -Cipher::~Cipher() {} +Cipher::~Cipher() = default; unsigned int Cipher::MAC_32(const unsigned char *src, int len, const CipherKey &key, uint64_t *chainedIV) const { diff --git a/encfs/CipherFileIO.cpp b/encfs/CipherFileIO.cpp index 40e3d5d..0a34efc 100644 --- a/encfs/CipherFileIO.cpp +++ b/encfs/CipherFileIO.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "BlockFileIO.h" #include "Cipher.h" @@ -47,10 +48,10 @@ static Interface CipherFileIO_iface("FileIO/Cipher", 2, 0, 1); const int HEADER_SIZE = 8; // 64 bit initialization vector.. -CipherFileIO::CipherFileIO(const std::shared_ptr &_base, +CipherFileIO::CipherFileIO(std::shared_ptr _base, const FSConfigPtr &cfg) : BlockFileIO(cfg->config->blockSize, cfg), - base(_base), + base(std::move(_base)), haveHeader(cfg->config->uniqueIV), externalIV(0), fileIV(0), @@ -63,7 +64,7 @@ CipherFileIO::CipherFileIO(const std::shared_ptr &_base, << "FS block size must be multiple of cipher block size"; } -CipherFileIO::~CipherFileIO() {} +CipherFileIO::~CipherFileIO() = default; Interface CipherFileIO::interface() const { return CipherFileIO_iface; } diff --git a/encfs/CipherFileIO.h b/encfs/CipherFileIO.h index a1bfd84..de88d85 100644 --- a/encfs/CipherFileIO.h +++ b/encfs/CipherFileIO.h @@ -45,7 +45,7 @@ struct IORequest; */ class CipherFileIO : public BlockFileIO { public: - CipherFileIO(const std::shared_ptr &base, const FSConfigPtr &cfg); + CipherFileIO(std::shared_ptr base, const FSConfigPtr &cfg); virtual ~CipherFileIO(); virtual Interface interface() const; diff --git a/encfs/CipherKey.cpp b/encfs/CipherKey.cpp index bf3f168..5a914e6 100644 --- a/encfs/CipherKey.cpp +++ b/encfs/CipherKey.cpp @@ -22,8 +22,8 @@ namespace encfs { -AbstractCipherKey::AbstractCipherKey() {} +AbstractCipherKey::AbstractCipherKey() = default; -AbstractCipherKey::~AbstractCipherKey() {} +AbstractCipherKey::~AbstractCipherKey() = default; } // namespace encfs diff --git a/encfs/ConfigReader.cpp b/encfs/ConfigReader.cpp index d3f52d1..9ad2912 100644 --- a/encfs/ConfigReader.cpp +++ b/encfs/ConfigReader.cpp @@ -33,9 +33,9 @@ using namespace std; namespace encfs { -ConfigReader::ConfigReader() {} +ConfigReader::ConfigReader() = default; -ConfigReader::~ConfigReader() {} +ConfigReader::~ConfigReader() = default; // read the entire file into a ConfigVar instance and then use that to decode // into mapped variables. diff --git a/encfs/Context.h b/encfs/Context.h index 201da47..8d62fcf 100644 --- a/encfs/Context.h +++ b/encfs/Context.h @@ -21,14 +21,14 @@ #ifndef _Context_incl_ #define _Context_incl_ -#include #include +#include +#include #include #include #include #include #include -#include #include "encfs.h" @@ -47,7 +47,7 @@ class EncFS_Context { std::shared_ptr lookupNode(const char *path); void getAndResetUsageCounter(int *usage, int *openCount); - + void putNode(const char *path, std::shared_ptr node); void eraseNode(const char *path, std::shared_ptr fnode); @@ -85,8 +85,7 @@ class EncFS_Context { * us. */ - typedef std::unordered_map>> + typedef std::unordered_map>> FileMap; mutable pthread_mutex_t contextMutex; diff --git a/encfs/DirNode.cpp b/encfs/DirNode.cpp index f3d32e6..2a39ef2 100644 --- a/encfs/DirNode.cpp +++ b/encfs/DirNode.cpp @@ -37,6 +37,7 @@ #include "internal/easylogging++.h" #include +#include #include "Context.h" #include "Error.h" @@ -51,20 +52,13 @@ class DirDeleter { void operator()(DIR *d) { ::closedir(d); } }; -DirTraverse::DirTraverse(const std::shared_ptr &_dirPtr, uint64_t _iv, - const std::shared_ptr &_naming) - : dir(_dirPtr), iv(_iv), naming(_naming) {} +DirTraverse::DirTraverse(std::shared_ptr _dirPtr, uint64_t _iv, + std::shared_ptr _naming) + : dir(std::move(_dirPtr)), iv(_iv), naming(std::move(_naming)) {} -DirTraverse::DirTraverse(const DirTraverse &src) - : dir(src.dir), iv(src.iv), naming(src.naming) {} +DirTraverse::DirTraverse(const DirTraverse &src) = default; -DirTraverse &DirTraverse::operator=(const DirTraverse &src) { - dir = src.dir; - iv = src.iv; - naming = src.naming; - - return *this; -} +DirTraverse &DirTraverse::operator=(const DirTraverse &src) = default; DirTraverse::~DirTraverse() { dir.reset(); @@ -143,13 +137,12 @@ class RenameOp { list::const_iterator last; public: - RenameOp(DirNode *_dn, const std::shared_ptr > &_renameList) - : dn(_dn), renameList(_renameList) { + RenameOp(DirNode *_dn, std::shared_ptr > _renameList) + : dn(_dn), renameList(std::move(_renameList)) { last = renameList->begin(); } - RenameOp(const RenameOp &src) - : dn(src.dn), renameList(src.renameList), last(src.last) {} + RenameOp(const RenameOp &src) = default; ~RenameOp(); @@ -252,7 +245,7 @@ DirNode::DirNode(EncFS_Context *_ctx, const string &sourceDir, naming = fsConfig->nameCoding; } -DirNode::~DirNode() {} +DirNode::~DirNode() = default; bool DirNode::hasDirectoryNameDependency() const { return naming ? naming->getChainedNameIV() : false; diff --git a/encfs/DirNode.h b/encfs/DirNode.h index a88082d..027fbea 100644 --- a/encfs/DirNode.h +++ b/encfs/DirNode.h @@ -48,8 +48,8 @@ struct RenameEl; class DirTraverse { public: - DirTraverse(const std::shared_ptr &dirPtr, uint64_t iv, - const std::shared_ptr &naming); + DirTraverse(std::shared_ptr dirPtr, uint64_t iv, + std::shared_ptr naming); DirTraverse(const DirTraverse &src); ~DirTraverse(); diff --git a/encfs/FileIO.cpp b/encfs/FileIO.cpp index ab9b363..2f653e0 100644 --- a/encfs/FileIO.cpp +++ b/encfs/FileIO.cpp @@ -22,9 +22,9 @@ namespace encfs { -FileIO::FileIO() {} +FileIO::FileIO() = default; -FileIO::~FileIO() {} +FileIO::~FileIO() = default; int FileIO::blockSize() const { return 1; } diff --git a/encfs/FileNode.h b/encfs/FileNode.h index b522200..22accf4 100644 --- a/encfs/FileNode.h +++ b/encfs/FileNode.h @@ -21,13 +21,13 @@ #ifndef _FileNode_incl_ #define _FileNode_incl_ +#include #include #include #include #include #include #include -#include #include "CipherKey.h" #include "FSConfig.h" diff --git a/encfs/FileUtils.cpp b/encfs/FileUtils.cpp index 2c4a8f3..23c2e9a 100644 --- a/encfs/FileUtils.cpp +++ b/encfs/FileUtils.cpp @@ -119,9 +119,9 @@ struct ConfigInfo { {".encfs", Config_Prehistoric, nullptr, nullptr, nullptr, 0, 0}, {nullptr, Config_None, nullptr, nullptr, nullptr, 0, 0}}; -EncFS_Root::EncFS_Root() {} +EncFS_Root::EncFS_Root() = default; -EncFS_Root::~EncFS_Root() {} +EncFS_Root::~EncFS_Root() = default; bool fileExists(const char *fileName) { struct stat buf; diff --git a/encfs/Interface.cpp b/encfs/Interface.cpp index 8cd8def..18fb6e0 100644 --- a/encfs/Interface.cpp +++ b/encfs/Interface.cpp @@ -20,6 +20,8 @@ #include "Interface.h" +#include + #include "ConfigVar.h" #include "Error.h" @@ -28,25 +30,19 @@ namespace encfs { Interface::Interface(const char *name_, int Current, int Revision, int Age) : _name(name_), _current(Current), _revision(Revision), _age(Age) {} -Interface::Interface(const std::string &name_, int Current, int Revision, - int Age) - : _name(name_), _current(Current), _revision(Revision), _age(Age) {} +Interface::Interface(std::string name_, int Current, int Revision, int Age) + : _name(std::move(name_)), + _current(Current), + _revision(Revision), + _age(Age) {} Interface::Interface(const Interface &src) - : _name(src._name), - _current(src._current), - _revision(src._revision), - _age(src._age) {} + + = default; Interface::Interface() : _current(0), _revision(0), _age(0) {} -Interface &Interface::operator=(const Interface &src) { - _name = src._name; - _current = src._current; - _revision = src._revision; - _age = src._age; - return *this; -} +Interface &Interface::operator=(const Interface &src) = default; const std::string &Interface::name() const { return _name; } diff --git a/encfs/Interface.h b/encfs/Interface.h index 2ec101a..d1cffba 100644 --- a/encfs/Interface.h +++ b/encfs/Interface.h @@ -37,7 +37,7 @@ class Interface { are implemented. */ Interface(const char *name, int Current, int Revision, int Age); - Interface(const std::string &name, int Current, int Revision, int Age); + Interface(std::string name, int Current, int Revision, int Age); Interface(const Interface &src); Interface(); diff --git a/encfs/MACFileIO.cpp b/encfs/MACFileIO.cpp index 6d2897f..e03a618 100644 --- a/encfs/MACFileIO.cpp +++ b/encfs/MACFileIO.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "BlockFileIO.h" #include "Cipher.h" @@ -56,10 +57,9 @@ int dataBlockSize(const FSConfigPtr &cfg) { cfg->config->blockMACRandBytes; } -MACFileIO::MACFileIO(const std::shared_ptr &_base, - const FSConfigPtr &cfg) +MACFileIO::MACFileIO(std::shared_ptr _base, const FSConfigPtr &cfg) : BlockFileIO(dataBlockSize(cfg), cfg), - base(_base), + base(std::move(_base)), cipher(cfg->cipher), key(cfg->key), macBytes(cfg->config->blockMACBytes), @@ -72,7 +72,7 @@ MACFileIO::MACFileIO(const std::shared_ptr &_base, << ", randBytes = " << cfg->config->blockMACRandBytes; } -MACFileIO::~MACFileIO() {} +MACFileIO::~MACFileIO() = default; Interface MACFileIO::interface() const { return MACFileIO_iface; } diff --git a/encfs/MACFileIO.h b/encfs/MACFileIO.h index 6bf4a25..fe39bf7 100644 --- a/encfs/MACFileIO.h +++ b/encfs/MACFileIO.h @@ -44,7 +44,7 @@ class MACFileIO : public BlockFileIO { result in a warning message from encfs -- the garbled data will still be made available.. */ - MACFileIO(const std::shared_ptr &base, const FSConfigPtr &cfg); + MACFileIO(std::shared_ptr base, const FSConfigPtr &cfg); MACFileIO(); virtual ~MACFileIO(); diff --git a/encfs/NameIO.cpp b/encfs/NameIO.cpp index 7dbf9dc..7a3ea52 100644 --- a/encfs/NameIO.cpp +++ b/encfs/NameIO.cpp @@ -127,7 +127,7 @@ std::shared_ptr NameIO::New(const Interface &iface, NameIO::NameIO() : chainedNameIV(false), reverseEncryption(false) {} -NameIO::~NameIO() {} +NameIO::~NameIO() = default; void NameIO::setChainedNameIV(bool enable) { chainedNameIV = enable; } diff --git a/encfs/NullCipher.cpp b/encfs/NullCipher.cpp index 4c787d6..4a6e05b 100644 --- a/encfs/NullCipher.cpp +++ b/encfs/NullCipher.cpp @@ -49,24 +49,24 @@ static bool NullCipher_registered = Cipher::Register( class NullKey : public AbstractCipherKey { public: - NullKey() {} - virtual ~NullKey() {} + NullKey() = default; + virtual ~NullKey() = default; }; class NullDestructor { public: - NullDestructor() {} - NullDestructor(const NullDestructor &) {} - ~NullDestructor() {} + NullDestructor() = default; + NullDestructor(const NullDestructor &) = default; + ~NullDestructor() = default; - NullDestructor &operator=(const NullDestructor &) { return *this; } + NullDestructor &operator=(const NullDestructor &) = default; void operator()(NullKey *&) {} }; std::shared_ptr gNullKey(new NullKey(), NullDestructor()); NullCipher::NullCipher(const Interface &iface_) { this->iface = iface_; } -NullCipher::~NullCipher() {} +NullCipher::~NullCipher() = default; Interface NullCipher::interface() const { return iface; } diff --git a/encfs/NullNameIO.cpp b/encfs/NullNameIO.cpp index a2f6e34..26b0251 100644 --- a/encfs/NullNameIO.cpp +++ b/encfs/NullNameIO.cpp @@ -41,9 +41,9 @@ static Interface NNIOIface("nameio/null", 1, 0, 0); static bool NullNameIO_registered = NameIO::Register("Null", "No encryption of filenames", NNIOIface, NewNNIO); -NullNameIO::NullNameIO() {} +NullNameIO::NullNameIO() = default; -NullNameIO::~NullNameIO() {} +NullNameIO::~NullNameIO() = default; Interface NullNameIO::interface() const { return NNIOIface; } diff --git a/encfs/RawFileIO.cpp b/encfs/RawFileIO.cpp index 1eb1e93..fdfaccd 100644 --- a/encfs/RawFileIO.cpp +++ b/encfs/RawFileIO.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "Error.h" #include "FileIO.h" @@ -53,8 +54,8 @@ inline void swap(int &x, int &y) { RawFileIO::RawFileIO() : knownSize(false), fileSize(0), fd(-1), oldfd(-1), canWrite(false) {} -RawFileIO::RawFileIO(const std::string &fileName) - : name(fileName), +RawFileIO::RawFileIO(std::string fileName) + : name(std::move(fileName)), knownSize(false), fileSize(0), fd(-1), diff --git a/encfs/RawFileIO.h b/encfs/RawFileIO.h index 1214a56..bd74fe6 100644 --- a/encfs/RawFileIO.h +++ b/encfs/RawFileIO.h @@ -32,7 +32,7 @@ namespace encfs { class RawFileIO : public FileIO { public: RawFileIO(); - RawFileIO(const std::string &fileName); + RawFileIO(std::string fileName); virtual ~RawFileIO(); virtual Interface interface() const; diff --git a/encfs/SSL_Cipher.cpp b/encfs/SSL_Cipher.cpp index a3ab05a..d0fb9e4 100644 --- a/encfs/SSL_Cipher.cpp +++ b/encfs/SSL_Cipher.cpp @@ -342,7 +342,7 @@ SSL_Cipher::SSL_Cipher(const Interface &iface_, const Interface &realIface_, } } -SSL_Cipher::~SSL_Cipher() {} +SSL_Cipher::~SSL_Cipher() = default; Interface SSL_Cipher::interface() const { return realIface; } diff --git a/encfs/SSL_Compat.h b/encfs/SSL_Compat.h index f7b1629..276bf26 100644 --- a/encfs/SSL_Compat.h +++ b/encfs/SSL_Compat.h @@ -30,8 +30,7 @@ #define HMAC_CTX_reset HMAC_CTX_cleanup // Missing methods (based on 1.1.0 versions) -HMAC_CTX *HMAC_CTX_new(void) -{ +HMAC_CTX *HMAC_CTX_new(void) { HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_malloc(sizeof(HMAC_CTX)); if (ctx != NULL) { memset(ctx, 0, sizeof(HMAC_CTX)); @@ -40,8 +39,7 @@ HMAC_CTX *HMAC_CTX_new(void) return ctx; } -void HMAC_CTX_free(HMAC_CTX *ctx) -{ +void HMAC_CTX_free(HMAC_CTX *ctx) { if (ctx != NULL) { HMAC_CTX_cleanup(ctx); OPENSSL_free(ctx); diff --git a/encfs/StreamNameIO.cpp b/encfs/StreamNameIO.cpp index e07c4e5..ec06852 100644 --- a/encfs/StreamNameIO.cpp +++ b/encfs/StreamNameIO.cpp @@ -22,6 +22,7 @@ #include "internal/easylogging++.h" #include +#include #include "Cipher.h" #include "CipherKey.h" @@ -72,11 +73,12 @@ Interface StreamNameIO::CurrentInterface() { } StreamNameIO::StreamNameIO(const Interface &iface, - const std::shared_ptr &cipher, - const CipherKey &key) - : _interface(iface.current()), _cipher(cipher), _key(key) {} + std::shared_ptr cipher, CipherKey key) + : _interface(iface.current()), + _cipher(std::move(cipher)), + _key(std::move(key)) {} -StreamNameIO::~StreamNameIO() {} +StreamNameIO::~StreamNameIO() = default; Interface StreamNameIO::interface() const { return CurrentInterface(); } diff --git a/encfs/StreamNameIO.h b/encfs/StreamNameIO.h index 5bb3134..43a417e 100644 --- a/encfs/StreamNameIO.h +++ b/encfs/StreamNameIO.h @@ -36,8 +36,8 @@ class StreamNameIO : public NameIO { public: static Interface CurrentInterface(); - StreamNameIO(const Interface &iface, const std::shared_ptr &cipher, - const CipherKey &key); + StreamNameIO(const Interface &iface, std::shared_ptr cipher, + CipherKey key); virtual ~StreamNameIO(); virtual Interface interface() const; diff --git a/encfs/XmlReader.cpp b/encfs/XmlReader.cpp index 4685f6d..33a343a 100644 --- a/encfs/XmlReader.cpp +++ b/encfs/XmlReader.cpp @@ -34,7 +34,7 @@ namespace encfs { -XmlValue::~XmlValue() {} +XmlValue::~XmlValue() = default; XmlValuePtr XmlValue::operator[](const char *path) const { return find(path); } @@ -139,7 +139,7 @@ class XmlNode : virtual public XmlValue { XmlNode(const tinyxml2::XMLElement *element_) : XmlValue(safeValueForNode(element_)), element(element_) {} - virtual ~XmlNode() {} + virtual ~XmlNode() = default; virtual XmlValuePtr find(const char *name) const { if (name[0] == '@') { @@ -164,7 +164,7 @@ struct XmlReader::XmlReaderData { XmlReader::XmlReader() : pd(new XmlReaderData()) {} -XmlReader::~XmlReader() {} +XmlReader::~XmlReader() = default; bool XmlReader::load(const char *fileName) { pd->doc.reset(new tinyxml2::XMLDocument());