Skip to content

Commit

Permalink
Print to stderr instead of dialog for WinFsp error
Browse files Browse the repository at this point in the history
Also reformat all the files
  • Loading branch information
netheril96 committed Mar 17, 2018
1 parent 5b498f5 commit 50eb960
Show file tree
Hide file tree
Showing 36 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion sources/btree_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,4 +735,4 @@ bool BtreeDirectory::empty()
auto root = get_root_node();
return root == nullptr || root->entries().empty();
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/btree_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ inline std::unique_ptr<FileBase> btree_make_file_from_type(int type, Args&&... a
}
throwInvalidArgumentException("Unrecognized file type");
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/case_fold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,4 @@ std::string case_fold(StringRef str)
}
return result;
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/case_fold.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ namespace securefs
{
uint32_t case_fold(uint32_t rune) noexcept;
std::string case_fold(StringRef str);
}
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ bool parse_config(const Json::Value& config,
encrypted_key.data(),
encrypted_key.size());
}
}
} // namespace

namespace securefs
{
Expand Down Expand Up @@ -1239,4 +1239,4 @@ int commands_main(int argc, const char* const* argv)
return 2;
}
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ class CommandBase
virtual void parse_cmdline(int argc, const char* const* argv) = 0;
virtual int execute() = 0;
};
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/common_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ void FileStream::setxattr(const char*, void*, size_t, int) { throw VFSException(
ssize_t FileStream::listxattr(char*, size_t) { throw VFSException(ENOTSUP); }

void FileStream::removexattr(const char*) { throw VFSException(ENOTSUP); }
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ void hkdf(const void* key,
hkdf_expand(key, key_len, info, info_len, output, out_len);
}
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ void libscrypt_scrypt(const uint8_t* passwd,
uint32_t p,
uint8_t* buf,
size_t buflen);
}
} // namespace securefs
11 changes: 6 additions & 5 deletions sources/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ securefs::InvalidArgumentException::~InvalidArgumentException(){}
throw ::securefs::FileTypeInconsistencyException();
}

[[noreturn]] void securefs::throwPOSIXExceptionDoNotUseDirectly(int err, std::string msg)
{
[[noreturn]] void securefs::throwPOSIXExceptionDoNotUseDirectly(int err, std::string msg) {
throw POSIXException(err, std::move(msg));
}

[[noreturn]] void securefs::throw_runtime_error(const char* msg) { throw std::runtime_error(msg); }

[[noreturn]] void securefs::throw_runtime_error(const std::string& msg)
[[noreturn]] void securefs::throw_runtime_error(const char* msg)
{
throw std::runtime_error(msg);
}

[[noreturn]] void securefs::throw_runtime_error(const std::string& msg) {
throw std::runtime_error(msg);
}

std::string securefs::VFSException::message() const
{
return securefs::OSService::stringify_system_error(m_errno);
Expand Down
2 changes: 1 addition & 1 deletion sources/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@ class FileTypeInconsistencyException : public ExceptionBase
[[noreturn]] void throw_runtime_error(const std::string&);

std::unique_ptr<const char, void (*)(const char*)> get_type_name(const std::exception& e) noexcept;
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/file_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ void FileTable::gc()
if (m_closed_ids.size() >= MAX_NUM_CLOSED)
eject();
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/file_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ inline AutoClosedFileBase create_as(FileTable& table, const id_type& id, int typ
{
return AutoClosedFileBase(&table, table.create_as(id, type));
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,4 @@ SimpleDirectory::~SimpleDirectory()
// Ignore exceptions in destructor
}
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,4 @@ class SimpleDirectory : public Directory

~SimpleDirectory();
};
}
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/lite_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,5 +475,5 @@ namespace lite
}
}
#endif
}
}
} // namespace lite
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/lite_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,5 @@ namespace lite
}
#endif
};
}
}
} // namespace lite
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/lite_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,5 +567,5 @@ namespace lite
opt->removexattr = &::securefs::lite::removexattr;
#endif
}
}
}
} // namespace lite
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/lite_operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ namespace lite
uint32_t position);
int removexattr(const char* path, const char* name);
#endif
}
}
} // namespace lite
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/lite_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@ namespace lite
return num_blocks * block_size
+ (residue > (iv_size + get_mac_size()) ? residue - iv_size - get_mac_size() : 0);
}
}
}
} // namespace lite
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/lite_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ namespace lite
length_type block_size,
length_type iv_size) noexcept;
};
}
}
} // namespace lite
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ Logger* Logger::create_file_logger(const std::string& path)
}

Logger* global_logger = Logger::create_stderr_logger();
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ extern Logger* global_logger;
#define INFO_LOG(...) GENERIC_LOG(securefs::kLogInfo, __VA_ARGS__)
#define WARN_LOG(...) GENERIC_LOG(securefs::kLogWarning, __VA_ARGS__)
#define ERROR_LOG(...) GENERIC_LOG(securefs::kLogError, __VA_ARGS__)
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/mystring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,4 @@ void base32_decode(const char* input, size_t size, std::string& output)
out[byte_index + 1] |= p.second;
}
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/mystring.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ inline std::string hexify(const ByteContainer& c)

void base32_encode(const byte* input, size_t size, std::string& output);
void base32_decode(const char* input, size_t size, std::string& output);
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/myutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ void warn_if_key_not_random(const byte* key, size_t size, const char* file, int
line);
}
}
}
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/myutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ scope_guard<Func> make_guard(Func&& f)
{
return scope_guard<Func>(std::forward<Func>(f));
}
}
} // namespace stdex

#endif

Expand Down Expand Up @@ -266,4 +266,4 @@ void warn_if_key_not_random(const Container& c, const char* file, int line) noex
{
warn_if_key_not_random(c.data(), c.size(), file, line);
}
}
} // namespace securefs
10 changes: 5 additions & 5 deletions sources/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ namespace operations
}

FileSystemContext::~FileSystemContext() {}
}
}
} // namespace operations
} // namespace securefs

using securefs::operations::FileSystemContext;

Expand Down Expand Up @@ -195,7 +195,7 @@ namespace internal
}

inline bool is_readonly(struct fuse_context* ctx) { return get_fs(ctx)->table.is_readonly(); }
}
} // namespace internal

namespace operations
{
Expand Down Expand Up @@ -797,5 +797,5 @@ namespace operations
opt->removexattr = &securefs::operations::removexattr;
#endif
}
}
}
} // namespace operations
} // namespace securefs
4 changes: 2 additions & 2 deletions sources/operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ namespace operations
uint32_t position);
int removexattr(const char* path, const char* name);
#endif
}
}
} // namespace operations
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,4 @@ class ConsoleColourSetter
// Returns null if fp is not connected to console/tty
static std::unique_ptr<ConsoleColourSetter> create_setter(FILE* fp);
};
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/scrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,4 @@ void libscrypt_scrypt(const uint8_t* passwd,
/* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
libscrypt_PBKDF2_SHA256(passwd, passwdlen, B, p * 128 * r, 1, buf, buflen);
}
}
} // namespace securefs
6 changes: 3 additions & 3 deletions sources/streams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ namespace internal

bool is_sparse() const noexcept override { return m_stream->is_sparse(); }
};
}
} // namespace internal

std::shared_ptr<StreamBase> make_stream_hmac(const key_type& key_,
const id_type& id_,
Expand Down Expand Up @@ -539,7 +539,7 @@ namespace internal

void flush_header() override { m_metastream.flush(); }
};
}
} // namespace internal

std::pair<std::shared_ptr<CryptStream>, std::shared_ptr<HeaderBase>>
make_cryptstream_aes_gcm(std::shared_ptr<StreamBase> data_stream,
Expand All @@ -563,4 +563,4 @@ make_cryptstream_aes_gcm(std::shared_ptr<StreamBase> data_stream,
header_size);
return {stream, stream};
}
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ make_cryptstream_aes_gcm(std::shared_ptr<StreamBase> data_stream,
unsigned block_size,
unsigned iv_size,
unsigned header_size = 32);
}
} // namespace securefs
2 changes: 1 addition & 1 deletion sources/unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,5 +645,5 @@ std::unique_ptr<const char, void (*)(const char*)> get_type_name(const std::exce
return {demangled, [](const char* ptr) { free((void*)ptr); }};
return {name, [](const char*) { /* no op */ }};
};
}
} // namespace securefs
#endif
17 changes: 8 additions & 9 deletions sources/win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@ class WindowsException : public SystemException
}
};

[[noreturn]] void throw_windows_exception(const wchar_t* funcname)
{
[[noreturn]] void throw_windows_exception(const wchar_t* funcname) {
DWORD err = GetLastError();
throw WindowsException(err, funcname);
}
Expand Down Expand Up @@ -1027,12 +1026,12 @@ std::string OSService::stringify_system_error(int errcode)
void windows_init(void)
{
::SetConsoleOutputCP(CP_UTF8);
if (::FspLoad(nullptr) != STATUS_SUCCESS) {
MessageBoxW(0, L"SecureFS cannot load WinFsp. "
"Please make sure you have WinFsp properly installed.",
L"Error", MB_OK | MB_ICONERROR);
abort();
}
if (::FspLoad(nullptr) != STATUS_SUCCESS)
{
fputs("SecureFS cannot load WinFsp. Please make sure you have WinFsp properly installed.\n",
stderr);
abort();
}

HMODULE hd = GetModuleHandleW(L"kernel32.dll");
best_get_time_func = reinterpret_cast<decltype(best_get_time_func)>(
Expand Down Expand Up @@ -1143,6 +1142,6 @@ std::unique_ptr<const char, void (*)(const char*)> get_type_name(const std::exce
{
return {typeid(e).name(), [](const char*) { /* no op */ }};
}
}
} // namespace securefs

#endif
4 changes: 2 additions & 2 deletions test/test_streams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ namespace dummy
};

const size_t DummyBlockStream::BLOCK_SIZE = 1000;
}
}
} // namespace dummy
} // namespace securefs

// Used for debugging
void dump_contents(const std::vector<byte>& bytes, const char* filename, size_t max_size)
Expand Down

0 comments on commit 50eb960

Please sign in to comment.