Fixed some more or less valid clang and clang-tidy errors.
This commit is contained in:
parent
97d68d31e8
commit
1549ef27a7
@ -169,6 +169,9 @@ StreamError FileStream::seek(std::intptr_t pos, SeekMode seekMode)
|
|||||||
case SeekMode::RELATIVE_TO_END:
|
case SeekMode::RELATIVE_TO_END:
|
||||||
origin = SEEK_END;
|
origin = SEEK_END;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
assert(!"Invalid value passed as seekMode!");
|
||||||
|
return StreamError::UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
const int result = std::fseek(handle, static_cast<long>(pos), origin);
|
const int result = std::fseek(handle, static_cast<long>(pos), origin);
|
||||||
if (result != 0 || std::ferror(handle)) {
|
if (result != 0 || std::ferror(handle)) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "./common_macros.hpp"
|
#include "./common_macros.hpp"
|
||||||
|
|
||||||
#define MIJIN_SCOPE_EXIT_NAMED(name) \
|
#define MIJIN_SCOPE_EXIT_NAMED(name) \
|
||||||
mijin::ScopeExitGuard name = [&]()
|
const mijin::ScopeExitGuard name = [&]()
|
||||||
|
|
||||||
#define MIJIN_SCOPE_EXIT MIJIN_SCOPE_EXIT_NAMED(MIJIN_CONCAT(MIJIN_CONCAT(scope_guard_, __LINE__), __))
|
#define MIJIN_SCOPE_EXIT MIJIN_SCOPE_EXIT_NAMED(MIJIN_CONCAT(MIJIN_CONCAT(scope_guard_, __LINE__), __))
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ namespace mijin
|
|||||||
class ScopeExitGuard
|
class ScopeExitGuard
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::function<void(void)> func;
|
mutable std::function<void(void)> func; // variable is declared const to make clang-tidy happy, but we still want to be able to reset()
|
||||||
public:
|
public:
|
||||||
template<typename TFunc>
|
template<typename TFunc>
|
||||||
inline ScopeExitGuard(TFunc&& func_) noexcept : func(std::forward<TFunc>(func_)) {}
|
inline ScopeExitGuard(TFunc&& func_) noexcept : func(std::forward<TFunc>(func_)) {}
|
||||||
@ -32,7 +32,7 @@ public:
|
|||||||
ScopeExitGuard& operator=(const ScopeExitGuard&) noexcept = delete;
|
ScopeExitGuard& operator=(const ScopeExitGuard&) noexcept = delete;
|
||||||
ScopeExitGuard& operator=(ScopeExitGuard&&) noexcept = delete;
|
ScopeExitGuard& operator=(ScopeExitGuard&&) noexcept = delete;
|
||||||
|
|
||||||
inline void reset() noexcept
|
inline void reset() const noexcept
|
||||||
{
|
{
|
||||||
func = {};
|
func = {};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user