modernize: unindent else after return

This commit is contained in:
Valient Gough 2017-08-03 22:43:14 -07:00
parent c37ab8e671
commit f9d22c4f18
No known key found for this signature in database
GPG Key ID: 33C65E29813C14DF
15 changed files with 148 additions and 190 deletions

View File

@ -73,25 +73,24 @@ ssize_t BlockFileIO::cacheReadOneBlock(const IORequest &req) const {
if (_cache.dataLen < len) len = _cache.dataLen; // Don't read past EOF if (_cache.dataLen < len) len = _cache.dataLen; // Don't read past EOF
memcpy(req.data, _cache.data, len); memcpy(req.data, _cache.data, len);
return len; return len;
} else {
if (_cache.dataLen > 0) clearCache(_cache, _blockSize);
// cache results of read -- issue reads for full blocks
IORequest tmp;
tmp.offset = req.offset;
tmp.data = _cache.data;
tmp.dataLen = _blockSize;
ssize_t result = readOneBlock(tmp);
if (result > 0) {
_cache.offset = req.offset;
_cache.dataLen = result; // the amount we really have
if (result > req.dataLen) {
result = req.dataLen; // only as much as requested
}
memcpy(req.data, _cache.data, result);
}
return result;
} }
if (_cache.dataLen > 0) clearCache(_cache, _blockSize);
// cache results of read -- issue reads for full blocks
IORequest tmp;
tmp.offset = req.offset;
tmp.data = _cache.data;
tmp.dataLen = _blockSize;
ssize_t result = readOneBlock(tmp);
if (result > 0) {
_cache.offset = req.offset;
_cache.dataLen = result; // the amount we really have
if (result > req.dataLen) {
result = req.dataLen; // only as much as requested
}
memcpy(req.data, _cache.data, result);
}
return result;
} }
bool BlockFileIO::cacheWriteOneBlock(const IORequest &req) { bool BlockFileIO::cacheWriteOneBlock(const IORequest &req) {
@ -123,52 +122,51 @@ ssize_t BlockFileIO::read(const IORequest &req) const {
// read completely within a single block -- can be handled as-is by // read completely within a single block -- can be handled as-is by
// readOneBlock(). // readOneBlock().
return cacheReadOneBlock(req); return cacheReadOneBlock(req);
} else { }
size_t size = req.dataLen; size_t size = req.dataLen;
// if the request is larger then a block, then request each block // if the request is larger then a block, then request each block
// individually // individually
MemBlock mb; // in case we need to allocate a temporary block.. MemBlock mb; // in case we need to allocate a temporary block..
IORequest blockReq; // for requests we may need to make IORequest blockReq; // for requests we may need to make
blockReq.dataLen = _blockSize; blockReq.dataLen = _blockSize;
blockReq.data = nullptr; blockReq.data = nullptr;
unsigned char *out = req.data; unsigned char *out = req.data;
while (size != 0u) { while (size != 0u) {
blockReq.offset = blockNum * _blockSize; blockReq.offset = blockNum * _blockSize;
// if we're reading a full block, then read directly into the // if we're reading a full block, then read directly into the
// result buffer instead of using a temporary // result buffer instead of using a temporary
if (partialOffset == 0 && size >= (size_t)_blockSize) { if (partialOffset == 0 && size >= (size_t)_blockSize) {
blockReq.data = out; blockReq.data = out;
} else { } else {
if (mb.data == nullptr) mb = MemoryPool::allocate(_blockSize); if (mb.data == nullptr) mb = MemoryPool::allocate(_blockSize);
blockReq.data = mb.data; blockReq.data = mb.data;
}
ssize_t readSize = cacheReadOneBlock(blockReq);
if (readSize <= partialOffset) break; // didn't get enough bytes
int cpySize = min((size_t)(readSize - partialOffset), size);
CHECK(cpySize <= readSize);
// if we read to a temporary buffer, then move the data
if (blockReq.data != out) {
memcpy(out, blockReq.data + partialOffset, cpySize);
}
result += cpySize;
size -= cpySize;
out += cpySize;
++blockNum;
partialOffset = 0;
if (readSize < _blockSize) break;
} }
if (mb.data != nullptr) MemoryPool::release(mb); ssize_t readSize = cacheReadOneBlock(blockReq);
if (readSize <= partialOffset) break; // didn't get enough bytes
int cpySize = min((size_t)(readSize - partialOffset), size);
CHECK(cpySize <= readSize);
// if we read to a temporary buffer, then move the data
if (blockReq.data != out) {
memcpy(out, blockReq.data + partialOffset, cpySize);
}
result += cpySize;
size -= cpySize;
out += cpySize;
++blockNum;
partialOffset = 0;
if (readSize < _blockSize) break;
} }
if (mb.data != nullptr) MemoryPool::release(mb);
return result; return result;
} }

View File

@ -91,9 +91,8 @@ Interface BlockNameIO::CurrentInterface(bool caseInsensitive) {
// implement major version 4 plus support for two prior versions // implement major version 4 plus support for two prior versions
if (caseInsensitive) { if (caseInsensitive) {
return Interface("nameio/block32", 4, 0, 2); return Interface("nameio/block32", 4, 0, 2);
} else {
return Interface("nameio/block", 4, 0, 2);
} }
return Interface("nameio/block", 4, 0, 2);
} }
BlockNameIO::BlockNameIO(const Interface &iface, std::shared_ptr<Cipher> cipher, BlockNameIO::BlockNameIO(const Interface &iface, std::shared_ptr<Cipher> cipher,
@ -121,9 +120,8 @@ int BlockNameIO::maxEncodedNameLen(int plaintextNameLen) const {
int encodedNameLen = numBlocks * _bs + 2; // 2 checksum bytes int encodedNameLen = numBlocks * _bs + 2; // 2 checksum bytes
if (_caseInsensitive) { if (_caseInsensitive) {
return B256ToB32Bytes(encodedNameLen); return B256ToB32Bytes(encodedNameLen);
} else {
return B256ToB64Bytes(encodedNameLen);
} }
return B256ToB64Bytes(encodedNameLen);
} }
int BlockNameIO::maxDecodedNameLen(int encodedNameLen) const { int BlockNameIO::maxDecodedNameLen(int encodedNameLen) const {

View File

@ -105,10 +105,9 @@ bool CipherFileIO::setIV(uint64_t iv) {
// duh -- there are no file headers for directories! // duh -- there are no file headers for directories!
externalIV = iv; externalIV = iv;
return base->setIV(iv); return base->setIV(iv);
} else {
VLOG(1) << "writeHeader failed to re-open for write";
return false;
} }
VLOG(1) << "writeHeader failed to re-open for write";
return false;
} }
initHeader(); initHeader();
} }
@ -391,9 +390,8 @@ bool CipherFileIO::blockWrite(unsigned char *buf, int size,
VLOG(1) << "Called blockWrite"; VLOG(1) << "Called blockWrite";
if (!fsConfig->reverseEncryption) { if (!fsConfig->reverseEncryption) {
return cipher->blockEncode(buf, size, _iv64, key); return cipher->blockEncode(buf, size, _iv64, key);
} else {
return cipher->blockDecode(buf, size, _iv64, key);
} }
return cipher->blockDecode(buf, size, _iv64, key);
} }
bool CipherFileIO::streamWrite(unsigned char *buf, int size, bool CipherFileIO::streamWrite(unsigned char *buf, int size,
@ -401,36 +399,32 @@ bool CipherFileIO::streamWrite(unsigned char *buf, int size,
VLOG(1) << "Called streamWrite"; VLOG(1) << "Called streamWrite";
if (!fsConfig->reverseEncryption) { if (!fsConfig->reverseEncryption) {
return cipher->streamEncode(buf, size, _iv64, key); return cipher->streamEncode(buf, size, _iv64, key);
} else {
return cipher->streamDecode(buf, size, _iv64, key);
} }
return cipher->streamDecode(buf, size, _iv64, key);
} }
bool CipherFileIO::blockRead(unsigned char *buf, int size, bool CipherFileIO::blockRead(unsigned char *buf, int size,
uint64_t _iv64) const { uint64_t _iv64) const {
if (fsConfig->reverseEncryption) { if (fsConfig->reverseEncryption) {
return cipher->blockEncode(buf, size, _iv64, key); return cipher->blockEncode(buf, size, _iv64, key);
} else {
if (_allowHoles) {
// special case - leave all 0's alone
for (int i = 0; i < size; ++i) {
if (buf[i] != 0) return cipher->blockDecode(buf, size, _iv64, key);
}
return true;
} else {
return cipher->blockDecode(buf, size, _iv64, key);
}
} }
if (_allowHoles) {
// special case - leave all 0's alone
for (int i = 0; i < size; ++i) {
if (buf[i] != 0) return cipher->blockDecode(buf, size, _iv64, key);
}
return true;
}
return cipher->blockDecode(buf, size, _iv64, key);
} }
bool CipherFileIO::streamRead(unsigned char *buf, int size, bool CipherFileIO::streamRead(unsigned char *buf, int size,
uint64_t _iv64) const { uint64_t _iv64) const {
if (fsConfig->reverseEncryption) { if (fsConfig->reverseEncryption) {
return cipher->streamEncode(buf, size, _iv64, key); return cipher->streamEncode(buf, size, _iv64, key);
} else {
return cipher->streamDecode(buf, size, _iv64, key);
} }
return cipher->streamDecode(buf, size, _iv64, key);
} }
int CipherFileIO::truncate(off_t size) { int CipherFileIO::truncate(off_t size) {
@ -519,11 +513,10 @@ ssize_t CipherFileIO::read(const IORequest &origReq) const {
VLOG(1) << "read " << readBytes << " bytes from backing file"; VLOG(1) << "read " << readBytes << " bytes from backing file";
if (readBytes < 0) { if (readBytes < 0) {
return readBytes; // Return error code return readBytes; // Return error code
} else {
ssize_t sum = headerBytes + readBytes;
VLOG(1) << "returning sum=" << sum;
return sum;
} }
ssize_t sum = headerBytes + readBytes;
VLOG(1) << "returning sum=" << sum;
return sum;
} }
bool CipherFileIO::isWritable() const { return base->isWritable(); } bool CipherFileIO::isWritable() const { return base->isWritable(); }

View File

@ -129,9 +129,8 @@ ConfigVar ConfigReader::operator[](const std::string &varName) const {
auto it = vars.find(varName); auto it = vars.find(varName);
if (it == vars.end()) { if (it == vars.end()) {
return ConfigVar(); return ConfigVar();
} else {
return it->second;
} }
return it->second;
} }
ConfigVar &ConfigReader::operator[](const std::string &varName) { ConfigVar &ConfigReader::operator[](const std::string &varName) {

View File

@ -45,9 +45,8 @@ ConfigVar::~ConfigVar() { pd.reset(); }
ConfigVar &ConfigVar::operator=(const ConfigVar &src) { ConfigVar &ConfigVar::operator=(const ConfigVar &src) {
if (src.pd == pd) { if (src.pd == pd) {
return *this; return *this;
} else {
pd = src.pd;
} }
pd = src.pd;
return *this; return *this;
} }
@ -142,9 +141,8 @@ int ConfigVar::readInt(int defaultValue) const {
if (offset >= bytes) { if (offset >= bytes) {
return defaultValue; return defaultValue;
} else {
return readInt();
} }
return readInt();
} }
bool ConfigVar::readBool(bool defaultValue) const { bool ConfigVar::readBool(bool defaultValue) const {

View File

@ -81,10 +81,9 @@ static bool _nextName(struct dirent *&de, const std::shared_ptr<DIR> &dir,
} }
if (inode != nullptr) *inode = de->d_ino; if (inode != nullptr) *inode = de->d_ino;
return true; return true;
} else {
if (fileType != nullptr) *fileType = 0;
return false;
} }
if (fileType != nullptr) *fileType = 0;
return false;
} }
std::string DirTraverse::nextPlaintextName(int *fileType, ino_t *inode) { std::string DirTraverse::nextPlaintextName(int *fileType, ino_t *inode) {
@ -350,19 +349,18 @@ DirTraverse DirNode::openDir(const char *plaintextPath) {
if (dir == nullptr) { if (dir == nullptr) {
VLOG(1) << "opendir error " << strerror(errno); VLOG(1) << "opendir error " << strerror(errno);
return DirTraverse(shared_ptr<DIR>(), 0, std::shared_ptr<NameIO>()); return DirTraverse(shared_ptr<DIR>(), 0, std::shared_ptr<NameIO>());
} else {
std::shared_ptr<DIR> dp(dir, DirDeleter());
uint64_t iv = 0;
// if we're using chained IV mode, then compute the IV at this
// directory level..
try {
if (naming->getChainedNameIV()) naming->encodePath(plaintextPath, &iv);
} catch (encfs::Error &err) {
RLOG(ERROR) << "encode err: " << err.what();
}
return DirTraverse(dp, iv, naming);
} }
std::shared_ptr<DIR> dp(dir, DirDeleter());
uint64_t iv = 0;
// if we're using chained IV mode, then compute the IV at this
// directory level..
try {
if (naming->getChainedNameIV()) naming->encodePath(plaintextPath, &iv);
} catch (encfs::Error &err) {
RLOG(ERROR) << "encode err: " << err.what();
}
return DirTraverse(dp, iv, naming);
} }
bool DirNode::genRenameList(list<RenameEl> &renameList, const char *fromP, bool DirNode::genRenameList(list<RenameEl> &renameList, const char *fromP,
@ -477,9 +475,8 @@ std::shared_ptr<RenameOp> DirNode::newRenameOp(const char *fromP,
if (!genRenameList(*renameList.get(), fromP, toP)) { if (!genRenameList(*renameList.get(), fromP, toP)) {
RLOG(WARNING) << "Error during generation of recursive rename list"; RLOG(WARNING) << "Error during generation of recursive rename list";
return std::shared_ptr<RenameOp>(); return std::shared_ptr<RenameOp>();
} else {
return std::make_shared<RenameOp>(this, renameList);
} }
return std::make_shared<RenameOp>(this, renameList);
} }
int DirNode::mkdir(const char *plaintextPath, mode_t mode, uid_t uid, int DirNode::mkdir(const char *plaintextPath, mode_t mode, uid_t uid,
@ -679,9 +676,8 @@ std::shared_ptr<FileNode> DirNode::openNode(const char *plainName,
if (node && (*result = node->open(flags)) >= 0) { if (node && (*result = node->open(flags)) >= 0) {
return node; return node;
} else {
return std::shared_ptr<FileNode>();
} }
return std::shared_ptr<FileNode>();
} }
int DirNode::unlink(const char *plaintextName) { int DirNode::unlink(const char *plaintextName) {

View File

@ -102,9 +102,8 @@ static bool setIV(const std::shared_ptr<FileIO> &io, uint64_t iv) {
struct stat stbuf; struct stat stbuf;
if ((io->getAttr(&stbuf) < 0) || S_ISREG(stbuf.st_mode)) { if ((io->getAttr(&stbuf) < 0) || S_ISREG(stbuf.st_mode)) {
return io->setIV(iv); return io->setIV(iv);
} else {
return true;
} }
return true;
} }
bool FileNode::setName(const char *plaintextName_, const char *cipherName_, bool FileNode::setName(const char *plaintextName_, const char *cipherName_,
@ -261,9 +260,8 @@ int FileNode::sync(bool datasync) {
if (res == -1) res = -errno; if (res == -1) res = -errno;
return res; return res;
} else {
return fh;
} }
return fh;
} }
} // namespace encfs } // namespace encfs

View File

@ -127,27 +127,24 @@ bool fileExists(const char *fileName) {
struct stat buf; struct stat buf;
if (lstat(fileName, &buf) == 0) { if (lstat(fileName, &buf) == 0) {
return true; return true;
} else {
// XXX show perror?
return false;
} }
// XXX show perror?
return false;
} }
bool isDirectory(const char *fileName) { bool isDirectory(const char *fileName) {
struct stat buf; struct stat buf;
if (lstat(fileName, &buf) == 0) { if (lstat(fileName, &buf) == 0) {
return S_ISDIR(buf.st_mode); return S_ISDIR(buf.st_mode);
} else {
return false;
} }
return false;
} }
bool isAbsolutePath(const char *fileName) { bool isAbsolutePath(const char *fileName) {
if ((fileName != nullptr) && fileName[0] != '\0' && fileName[0] == '/') { if ((fileName != nullptr) && fileName[0] != '\0' && fileName[0] == '/') {
return true; return true;
} else {
return false;
} }
return false;
} }
const char *lastPathElement(const char *name) { const char *lastPathElement(const char *name) {
@ -159,9 +156,8 @@ std::string parentDirectory(const std::string &path) {
size_t last = path.find_last_of('/'); size_t last = path.find_last_of('/');
if (last == string::npos) { if (last == string::npos) {
return string(""); return string("");
} else {
return path.substr(0, last);
} }
return path.substr(0, last);
} }
bool userAllowMkdir(const char *path, mode_t mode) { bool userAllowMkdir(const char *path, mode_t mode) {
@ -196,14 +192,12 @@ bool userAllowMkdir(int promptno, const char *path, mode_t mode) {
if (result < 0) { if (result < 0) {
perror(_("Unable to create directory: ")); perror(_("Unable to create directory: "));
return false; return false;
} else {
return true;
} }
} else { return true;
// Directory not created, by user request
cerr << _("Directory not created.") << "\n";
return false;
} }
// Directory not created, by user request
cerr << _("Directory not created.") << "\n";
return false;
} }
/** /**
@ -842,10 +836,12 @@ static bool boolDefault(const char *prompt, bool defaultValue) {
if (cin.fail() || response == "") { if (cin.fail() || response == "") {
value = defaultValue; value = defaultValue;
break; break;
} else if (response == "y") { }
if (response == "y") {
value = true; value = true;
break; break;
} else if (response == "n") { }
if (response == "n") {
value = false; value = false;
break; break;
} }
@ -1119,10 +1115,9 @@ RootPtr createV6Config(EncFS_Context *ctx,
_("Unable to instanciate cipher %s, key size %i, block size %i"), _("Unable to instanciate cipher %s, key size %i, block size %i"),
alg.name.c_str(), keySize, blockSize); alg.name.c_str(), keySize, blockSize);
return rootInfo; return rootInfo;
} else {
VLOG(1) << "Using cipher " << alg.name << ", key size " << keySize
<< ", block size " << blockSize;
} }
VLOG(1) << "Using cipher " << alg.name << ", key size " << keySize
<< ", block size " << blockSize;
std::shared_ptr<EncFSConfig> config(new EncFSConfig); std::shared_ptr<EncFSConfig> config(new EncFSConfig);
@ -1672,10 +1667,9 @@ int remountFS(EncFS_Context *ctx) {
if (rootInfo) { if (rootInfo) {
ctx->setRoot(rootInfo->root); ctx->setRoot(rootInfo->root);
return 0; return 0;
} else {
RLOG(WARNING) << "Remount failed";
return -EACCES;
} }
RLOG(WARNING) << "Remount failed";
return -EACCES;
} }
} // namespace encfs } // namespace encfs

View File

@ -85,11 +85,11 @@ static int sign( int a, int b )
static int sign(int a, int b) { static int sign(int a, int b) {
if (a < b) { if (a < b) {
return 0; return 0;
} else if (a == b) {
return 1;
} else {
return 2;
} }
if (a == b) {
return 1;
}
return 2;
} }
#endif #endif
@ -117,33 +117,29 @@ bool Interface::implements(const Interface &B) const {
bool operator<(const Interface &A, const Interface &B) { bool operator<(const Interface &A, const Interface &B) {
if (A.name() == B.name()) { if (A.name() == B.name()) {
return (diffSum(A, B) < EqualVersion); return (diffSum(A, B) < EqualVersion);
} else {
return A.name() < B.name();
} }
return A.name() < B.name();
} }
bool operator>(const Interface &A, const Interface &B) { bool operator>(const Interface &A, const Interface &B) {
if (A.name() == B.name()) { if (A.name() == B.name()) {
return (diffSum(A, B) > EqualVersion); return (diffSum(A, B) > EqualVersion);
} else {
return A.name() < B.name();
} }
return A.name() < B.name();
} }
bool operator<=(const Interface &A, const Interface &B) { bool operator<=(const Interface &A, const Interface &B) {
if (A.name() == B.name()) { if (A.name() == B.name()) {
return (diffSum(A, B) <= EqualVersion); return (diffSum(A, B) <= EqualVersion);
} else {
return A.name() < B.name();
} }
return A.name() < B.name();
} }
bool operator>=(const Interface &A, const Interface &B) { bool operator>=(const Interface &A, const Interface &B) {
if (A.name() == B.name()) { if (A.name() == B.name()) {
return (diffSum(A, B) >= EqualVersion); return (diffSum(A, B) >= EqualVersion);
} else {
return A.name() < B.name();
} }
return A.name() < B.name();
} }
ConfigVar &operator<<(ConfigVar &dst, const Interface &iface) { ConfigVar &operator<<(ConfigVar &dst, const Interface &iface) {

View File

@ -185,13 +185,11 @@ off_t RawFileIO::getSize() const {
const_cast<RawFileIO *>(this)->fileSize = stbuf.st_size; const_cast<RawFileIO *>(this)->fileSize = stbuf.st_size;
const_cast<RawFileIO *>(this)->knownSize = true; const_cast<RawFileIO *>(this)->knownSize = true;
return fileSize; return fileSize;
} else {
RLOG(ERROR) << "getSize on " << name << " failed: " << strerror(errno);
return -1;
} }
} else { RLOG(ERROR) << "getSize on " << name << " failed: " << strerror(errno);
return fileSize; return -1;
} }
return fileSize;
} }
ssize_t RawFileIO::read(const IORequest &req) const { ssize_t RawFileIO::read(const IORequest &req) const {
@ -237,14 +235,13 @@ bool RawFileIO::write(const IORequest &req) {
<< req.dataLen << ", max retries reached"; << req.dataLen << ", max retries reached";
knownSize = false; knownSize = false;
return false; return false;
} else {
if (knownSize) {
off_t last = req.offset + req.dataLen;
if (last > fileSize) fileSize = last;
}
return true;
} }
if (knownSize) {
off_t last = req.offset + req.dataLen;
if (last > fileSize) fileSize = last;
}
return true;
} }
int RawFileIO::truncate(off_t size) { int RawFileIO::truncate(off_t size) {

View File

@ -368,9 +368,9 @@ CipherKey SSL_Cipher::newKey(const char *password, int passwdLength,
if (res <= 0) { if (res <= 0) {
RLOG(WARNING) << "openssl error, PBKDF2 failed"; RLOG(WARNING) << "openssl error, PBKDF2 failed";
return CipherKey(); return CipherKey();
} else {
iterationCount = res;
} }
iterationCount = res;
} else { } else {
// known iteration length // known iteration length
if (PKCS5_PBKDF2_HMAC_SHA1( if (PKCS5_PBKDF2_HMAC_SHA1(
@ -510,9 +510,8 @@ bool SSL_Cipher::randomize(unsigned char *buf, int len,
} }
return false; return false;
} else {
return true;
} }
return true;
} }
uint64_t SSL_Cipher::MAC_64(const unsigned char *data, int len, uint64_t SSL_Cipher::MAC_64(const unsigned char *data, int len,
@ -599,9 +598,8 @@ bool SSL_Cipher::compareKey(const CipherKey &A, const CipherKey &B) const {
if (memcmp(key1->buffer, key2->buffer, _keySize + _ivLength) != 0) { if (memcmp(key1->buffer, key2->buffer, _keySize + _ivLength) != 0) {
return false; return false;
} else {
return true;
} }
return true;
} }
int SSL_Cipher::encodedKeySize() const { int SSL_Cipher::encodedKeySize() const {

View File

@ -146,17 +146,14 @@ class XmlNode : virtual public XmlValue {
const char *value = element->Attribute(name + 1); const char *value = element->Attribute(name + 1);
if (value != nullptr) { if (value != nullptr) {
return std::make_shared<encfs::XmlValue>(value); return std::make_shared<encfs::XmlValue>(value);
} else {
return XmlValuePtr();
}
} else {
const tinyxml2::XMLElement *el = element->FirstChildElement(name);
if (el != nullptr) {
return XmlValuePtr(new XmlNode(el));
} else {
return XmlValuePtr();
} }
return XmlValuePtr();
} }
const tinyxml2::XMLElement *el = element->FirstChildElement(name);
if (el != nullptr) {
return XmlValuePtr(new XmlNode(el));
}
return XmlValuePtr();
} }
}; };

View File

@ -57,9 +57,8 @@ autosprintf::operator char *() const {
auto *copy = new char[length]; auto *copy = new char[length];
memcpy(copy, str, length); memcpy(copy, str, length);
return copy; return copy;
} else {
return nullptr;
} }
return nullptr;
} }
autosprintf::operator std::string() const { autosprintf::operator std::string() const {
return std::string(str != nullptr ? str : "(error in autosprintf)"); return std::string(str != nullptr ? str : "(error in autosprintf)");

View File

@ -397,10 +397,9 @@ int _do_readlink(EncFS_Context *ctx, const string &cyName, char *buf,
buf[size - 1] = '\0'; buf[size - 1] = '\0';
return ESUCCESS; return ESUCCESS;
} else {
RLOG(WARNING) << "Error decoding link";
return -1;
} }
RLOG(WARNING) << "Error decoding link";
return -1;
} }
int encfs_readlink(const char *path, char *buf, size_t size) { int encfs_readlink(const char *path, char *buf, size_t size) {
@ -655,9 +654,8 @@ int encfs_fsync(const char *path, int dataSync, struct fuse_file_info *file) {
int _do_write(FileNode *fnode, unsigned char *ptr, size_t size, off_t offset) { int _do_write(FileNode *fnode, unsigned char *ptr, size_t size, off_t offset) {
if (fnode->write(offset, ptr, size)) { if (fnode->write(offset, ptr, size)) {
return size; return size;
} else {
return -EIO;
} }
return -EIO;
} }
int encfs_write(const char *path, const char *buf, size_t size, off_t offset, int encfs_write(const char *path, const char *buf, size_t size, off_t offset,

View File

@ -785,15 +785,14 @@ static bool unmountFS(EncFS_Context *ctx) {
ctx->setRoot(std::shared_ptr<DirNode>()); ctx->setRoot(std::shared_ptr<DirNode>());
return false; return false;
} else { }
// Time to unmount! // Time to unmount!
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
fuse_unmount(arg->opts->mountPoint.c_str(), nullptr); fuse_unmount(arg->opts->mountPoint.c_str(), nullptr);
#else #else
fuse_unmount(fuse_get_context()->fuse); fuse_unmount(fuse_get_context()->fuse);
#endif #endif
// fuse_unmount succeeds and returns void // fuse_unmount succeeds and returns void
RLOG(INFO) << "Filesystem inactive, unmounted: " << arg->opts->mountPoint; RLOG(INFO) << "Filesystem inactive, unmounted: " << arg->opts->mountPoint;
return true; return true;
}
} }