diff --git a/encfs/Context.cpp b/encfs/Context.cpp index 16ec724..f8151b9 100644 --- a/encfs/Context.cpp +++ b/encfs/Context.cpp @@ -75,7 +75,7 @@ void EncFS_Context::setRoot(const std::shared_ptr &r) { } } -bool EncFS_Context::isMounted() { return root.get() != nullptr; } +bool EncFS_Context::isMounted() { return root != nullptr; } void EncFS_Context::getAndResetUsageCounter(int *usage, int *openCount) { Lock lock(contextMutex); diff --git a/encfs/DirNode.cpp b/encfs/DirNode.cpp index 1c0f78c..2494084 100644 --- a/encfs/DirNode.cpp +++ b/encfs/DirNode.cpp @@ -149,7 +149,7 @@ class RenameOp { ~RenameOp(); - operator bool() const { return renameList.get() != nullptr; } + operator bool() const { return renameList != nullptr; } bool apply(); void undo(); @@ -659,21 +659,21 @@ std::shared_ptr DirNode::findOrCreate(const char *plainName) { // See if we already have a FileNode for this path. if (ctx != nullptr) { node = ctx->lookupNode(plainName); - } - // If we don't, create a new one. - if (!node) { - uint64_t iv = 0; - string cipherName = naming->encodePath(plainName, &iv); - uint64_t fuseFh = ctx->nextFuseFh(); - node.reset(new FileNode(this, fsConfig, plainName, - (rootDir + cipherName).c_str(), fuseFh)); + // If we don't, create a new one. + if (!node) { + uint64_t iv = 0; + string cipherName = naming->encodePath(plainName, &iv); + uint64_t fuseFh = ctx->nextFuseFh(); + node.reset(new FileNode(this, fsConfig, plainName, + (rootDir + cipherName).c_str(), fuseFh)); - if (fsConfig->config->externalIVChaining) { - node->setName(nullptr, nullptr, iv); + if (fsConfig->config->externalIVChaining) { + node->setName(nullptr, nullptr, iv); + } + + VLOG(1) << "created FileNode for " << node->cipherName(); } - - VLOG(1) << "created FileNode for " << node->cipherName(); } return node; diff --git a/encfs/FileUtils.cpp b/encfs/FileUtils.cpp index 4e67ac9..3374ce5 100644 --- a/encfs/FileUtils.cpp +++ b/encfs/FileUtils.cpp @@ -125,11 +125,7 @@ EncFS_Root::~EncFS_Root() = default; bool fileExists(const char *fileName) { struct stat buf; - if (lstat(fileName, &buf) == 0) { - return true; - } - // XXX show perror? - return false; + return lstat(fileName, &buf) == 0; } bool isDirectory(const char *fileName) { @@ -141,10 +137,7 @@ bool isDirectory(const char *fileName) { } bool isAbsolutePath(const char *fileName) { - if ((fileName != nullptr) && fileName[0] != '\0' && fileName[0] == '/') { - return true; - } - return false; + return (fileName != nullptr) && fileName[0] != '\0' && fileName[0] == '/'; } const char *lastPathElement(const char *name) { @@ -1306,7 +1299,7 @@ void showFSInfo(const EncFSConfig *config) { cout << "\n"; } } - if (config->kdfIterations > 0 && config->salt.size() > 0) { + if (config->kdfIterations > 0 && !config->salt.empty()) { cout << autosprintf(_("Using PBKDF2, with %i iterations"), config->kdfIterations) << "\n"; @@ -1389,12 +1382,12 @@ CipherKey EncFSConfig::makeKey(const char *password, int passwdLen) { // if no salt is set and we're creating a new password for a new // FS type, then initialize salt.. - if (salt.size() == 0 && kdfIterations == 0 && cfgType >= Config_V6) { + if (salt.empty() && kdfIterations == 0 && cfgType >= Config_V6) { // upgrade to using salt salt.resize(20); } - if (salt.size() > 0) { + if (!salt.empty()) { // if iterations isn't known, then we're creating a new key, so // randomize the salt.. if (kdfIterations == 0 && diff --git a/encfs/SSL_Cipher.cpp b/encfs/SSL_Cipher.cpp index f2b86a8..d0cb1fd 100644 --- a/encfs/SSL_Cipher.cpp +++ b/encfs/SSL_Cipher.cpp @@ -414,9 +414,8 @@ CipherKey SSL_Cipher::newKey(const char *password, int passwdLength) { } } else { // for backward compatibility with filesystems created with 1:0 - bytes = EVP_BytesToKey(_blockCipher, EVP_sha1(), nullptr, - (unsigned char *)password, passwdLength, 16, - KeyData(key), IVData(key)); + EVP_BytesToKey(_blockCipher, EVP_sha1(), nullptr, (unsigned char *)password, + passwdLength, 16, KeyData(key), IVData(key)); } initKey(key, _blockCipher, _streamCipher, _keySize); @@ -610,10 +609,7 @@ bool SSL_Cipher::compareKey(const CipherKey &A, const CipherKey &B) const { rAssert(key1->keySize == _keySize); rAssert(key2->keySize == _keySize); - if (memcmp(key1->buffer, key2->buffer, _keySize + _ivLength) != 0) { - return false; - } - return true; + return memcmp(key1->buffer, key2->buffer, _keySize + _ivLength) == 0; } int SSL_Cipher::encodedKeySize() const {