mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 15:33:16 +01:00
modernize: =default, pass by value
This commit is contained in:
parent
169101c80b
commit
71e2bcc84d
@ -22,6 +22,7 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#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> &cipher,
|
||||
const CipherKey &key, int blockSize,
|
||||
BlockNameIO::BlockNameIO(const Interface &iface, std::shared_ptr<Cipher> 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);
|
||||
|
@ -41,8 +41,8 @@ class BlockNameIO : public NameIO {
|
||||
public:
|
||||
static Interface CurrentInterface(bool caseInsensitive = false);
|
||||
|
||||
BlockNameIO(const Interface &iface, const std::shared_ptr<Cipher> &cipher,
|
||||
const CipherKey &key, int blockSize,
|
||||
BlockNameIO(const Interface &iface, std::shared_ptr<Cipher> cipher,
|
||||
CipherKey key, int blockSize,
|
||||
bool caseInsensitiveEncoding = false);
|
||||
virtual ~BlockNameIO();
|
||||
|
||||
|
@ -148,9 +148,9 @@ std::shared_ptr<Cipher> 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 {
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <memory>
|
||||
#include <openssl/sha.h>
|
||||
#include <sys/stat.h>
|
||||
#include <utility>
|
||||
|
||||
#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<FileIO> &_base,
|
||||
CipherFileIO::CipherFileIO(std::shared_ptr<FileIO> _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<FileIO> &_base,
|
||||
<< "FS block size must be multiple of cipher block size";
|
||||
}
|
||||
|
||||
CipherFileIO::~CipherFileIO() {}
|
||||
CipherFileIO::~CipherFileIO() = default;
|
||||
|
||||
Interface CipherFileIO::interface() const { return CipherFileIO_iface; }
|
||||
|
||||
|
@ -45,7 +45,7 @@ struct IORequest;
|
||||
*/
|
||||
class CipherFileIO : public BlockFileIO {
|
||||
public:
|
||||
CipherFileIO(const std::shared_ptr<FileIO> &base, const FSConfigPtr &cfg);
|
||||
CipherFileIO(std::shared_ptr<FileIO> base, const FSConfigPtr &cfg);
|
||||
virtual ~CipherFileIO();
|
||||
|
||||
virtual Interface interface() const;
|
||||
|
@ -22,8 +22,8 @@
|
||||
|
||||
namespace encfs {
|
||||
|
||||
AbstractCipherKey::AbstractCipherKey() {}
|
||||
AbstractCipherKey::AbstractCipherKey() = default;
|
||||
|
||||
AbstractCipherKey::~AbstractCipherKey() {}
|
||||
AbstractCipherKey::~AbstractCipherKey() = default;
|
||||
|
||||
} // namespace encfs
|
||||
|
@ -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.
|
||||
|
@ -21,14 +21,14 @@
|
||||
#ifndef _Context_incl_
|
||||
#define _Context_incl_
|
||||
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <pthread.h>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <atomic>
|
||||
|
||||
#include "encfs.h"
|
||||
|
||||
@ -47,7 +47,7 @@ class EncFS_Context {
|
||||
std::shared_ptr<FileNode> lookupNode(const char *path);
|
||||
|
||||
void getAndResetUsageCounter(int *usage, int *openCount);
|
||||
|
||||
|
||||
void putNode(const char *path, std::shared_ptr<FileNode> node);
|
||||
|
||||
void eraseNode(const char *path, std::shared_ptr<FileNode> fnode);
|
||||
@ -85,8 +85,7 @@ class EncFS_Context {
|
||||
* us.
|
||||
*/
|
||||
|
||||
typedef std::unordered_map<std::string,
|
||||
std::list<std::shared_ptr<FileNode>>>
|
||||
typedef std::unordered_map<std::string, std::list<std::shared_ptr<FileNode>>>
|
||||
FileMap;
|
||||
|
||||
mutable pthread_mutex_t contextMutex;
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include "internal/easylogging++.h"
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#include "Context.h"
|
||||
#include "Error.h"
|
||||
@ -51,20 +52,13 @@ class DirDeleter {
|
||||
void operator()(DIR *d) { ::closedir(d); }
|
||||
};
|
||||
|
||||
DirTraverse::DirTraverse(const std::shared_ptr<DIR> &_dirPtr, uint64_t _iv,
|
||||
const std::shared_ptr<NameIO> &_naming)
|
||||
: dir(_dirPtr), iv(_iv), naming(_naming) {}
|
||||
DirTraverse::DirTraverse(std::shared_ptr<DIR> _dirPtr, uint64_t _iv,
|
||||
std::shared_ptr<NameIO> _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<RenameEl>::const_iterator last;
|
||||
|
||||
public:
|
||||
RenameOp(DirNode *_dn, const std::shared_ptr<list<RenameEl> > &_renameList)
|
||||
: dn(_dn), renameList(_renameList) {
|
||||
RenameOp(DirNode *_dn, std::shared_ptr<list<RenameEl> > _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;
|
||||
|
@ -48,8 +48,8 @@ struct RenameEl;
|
||||
|
||||
class DirTraverse {
|
||||
public:
|
||||
DirTraverse(const std::shared_ptr<DIR> &dirPtr, uint64_t iv,
|
||||
const std::shared_ptr<NameIO> &naming);
|
||||
DirTraverse(std::shared_ptr<DIR> dirPtr, uint64_t iv,
|
||||
std::shared_ptr<NameIO> naming);
|
||||
DirTraverse(const DirTraverse &src);
|
||||
~DirTraverse();
|
||||
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
namespace encfs {
|
||||
|
||||
FileIO::FileIO() {}
|
||||
FileIO::FileIO() = default;
|
||||
|
||||
FileIO::~FileIO() {}
|
||||
FileIO::~FileIO() = default;
|
||||
|
||||
int FileIO::blockSize() const { return 1; }
|
||||
|
||||
|
@ -21,13 +21,13 @@
|
||||
#ifndef _FileNode_incl_
|
||||
#define _FileNode_incl_
|
||||
|
||||
#include <atomic>
|
||||
#include <inttypes.h>
|
||||
#include <memory>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
#include <atomic>
|
||||
|
||||
#include "CipherKey.h"
|
||||
#include "FSConfig.h"
|
||||
|
@ -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;
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "Interface.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#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; }
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
#include <sys/stat.h>
|
||||
#include <utility>
|
||||
|
||||
#include "BlockFileIO.h"
|
||||
#include "Cipher.h"
|
||||
@ -56,10 +57,9 @@ int dataBlockSize(const FSConfigPtr &cfg) {
|
||||
cfg->config->blockMACRandBytes;
|
||||
}
|
||||
|
||||
MACFileIO::MACFileIO(const std::shared_ptr<FileIO> &_base,
|
||||
const FSConfigPtr &cfg)
|
||||
MACFileIO::MACFileIO(std::shared_ptr<FileIO> _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<FileIO> &_base,
|
||||
<< ", randBytes = " << cfg->config->blockMACRandBytes;
|
||||
}
|
||||
|
||||
MACFileIO::~MACFileIO() {}
|
||||
MACFileIO::~MACFileIO() = default;
|
||||
|
||||
Interface MACFileIO::interface() const { return MACFileIO_iface; }
|
||||
|
||||
|
@ -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<FileIO> &base, const FSConfigPtr &cfg);
|
||||
MACFileIO(std::shared_ptr<FileIO> base, const FSConfigPtr &cfg);
|
||||
MACFileIO();
|
||||
virtual ~MACFileIO();
|
||||
|
||||
|
@ -127,7 +127,7 @@ std::shared_ptr<NameIO> NameIO::New(const Interface &iface,
|
||||
|
||||
NameIO::NameIO() : chainedNameIV(false), reverseEncryption(false) {}
|
||||
|
||||
NameIO::~NameIO() {}
|
||||
NameIO::~NameIO() = default;
|
||||
|
||||
void NameIO::setChainedNameIV(bool enable) { chainedNameIV = enable; }
|
||||
|
||||
|
@ -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<AbstractCipherKey> gNullKey(new NullKey(), NullDestructor());
|
||||
|
||||
NullCipher::NullCipher(const Interface &iface_) { this->iface = iface_; }
|
||||
|
||||
NullCipher::~NullCipher() {}
|
||||
NullCipher::~NullCipher() = default;
|
||||
|
||||
Interface NullCipher::interface() const { return iface; }
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
|
||||
#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),
|
||||
|
@ -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;
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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);
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "internal/easylogging++.h"
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#include "Cipher.h"
|
||||
#include "CipherKey.h"
|
||||
@ -72,11 +73,12 @@ Interface StreamNameIO::CurrentInterface() {
|
||||
}
|
||||
|
||||
StreamNameIO::StreamNameIO(const Interface &iface,
|
||||
const std::shared_ptr<Cipher> &cipher,
|
||||
const CipherKey &key)
|
||||
: _interface(iface.current()), _cipher(cipher), _key(key) {}
|
||||
std::shared_ptr<Cipher> 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(); }
|
||||
|
||||
|
@ -36,8 +36,8 @@ class StreamNameIO : public NameIO {
|
||||
public:
|
||||
static Interface CurrentInterface();
|
||||
|
||||
StreamNameIO(const Interface &iface, const std::shared_ptr<Cipher> &cipher,
|
||||
const CipherKey &key);
|
||||
StreamNameIO(const Interface &iface, std::shared_ptr<Cipher> cipher,
|
||||
CipherKey key);
|
||||
virtual ~StreamNameIO();
|
||||
|
||||
virtual Interface interface() const;
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user