From f2d578555bf51da7a0acd1d1d7e724860b89a149 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 25 Oct 2024 15:11:04 +0200 Subject: Fix a minor assert message + code boyscouting --- src/allocator.h | 8 +++++--- src/cancel.cpp | 6 +++--- src/lane.cpp | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/allocator.h b/src/allocator.h index e0ff9d6..3f8ccc5 100644 --- a/src/allocator.h +++ b/src/allocator.h @@ -28,23 +28,25 @@ namespace lanes { , allocUD{ allocUD_ } { } + + // rule of 5 AllocatorDefinition() = default; AllocatorDefinition(AllocatorDefinition const& rhs_) = default; AllocatorDefinition(AllocatorDefinition&& rhs_) = default; AllocatorDefinition& operator=(AllocatorDefinition const& rhs_) = default; AllocatorDefinition& operator=(AllocatorDefinition&& rhs_) = default; - void initFrom(lua_State* L_) + void initFrom(lua_State* const L_) { allocF = lua_getallocf(L_, &allocUD); } - void* alloc(size_t nsize_) + void* alloc(size_t const nsize_) { return allocF(allocUD, nullptr, 0, nsize_); } - void free(void* ptr_, size_t osize_) + void free(void* const ptr_, size_t const osize_) { std::ignore = allocF(allocUD, ptr_, osize_, 0); } diff --git a/src/cancel.cpp b/src/cancel.cpp index 2d0b807..46ed347 100644 --- a/src/cancel.cpp +++ b/src/cancel.cpp @@ -52,7 +52,7 @@ THE SOFTWARE. */ [[nodiscard]] CancelRequest CheckCancelRequest(lua_State* const L_) { - Lane* const _lane{ kLanePointerRegKey.readLightUserDataValue(L_) }; + auto const* const _lane{ kLanePointerRegKey.readLightUserDataValue(L_) }; // 'lane' is nullptr for the original main state (and no-one can cancel that) return _lane ? _lane->cancelRequest : CancelRequest::None; } @@ -82,7 +82,7 @@ THE SOFTWARE. CancelOp WhichCancelOp(std::string_view const& opString_) { - CancelOp _op{ CancelOp::Invalid }; + auto _op{ CancelOp::Invalid }; if (opString_ == "hard") { _op = CancelOp::Hard; } else if (opString_ == "soft") { @@ -110,7 +110,7 @@ CancelOp WhichCancelOp(std::string_view const& opString_) CancelOp _op{ WhichCancelOp(_str) }; lua_remove(L_, idx_); // argument is processed, remove it if (_op == CancelOp::Invalid) { - raise_luaL_error(L_, "invalid hook option %s", _str); + raise_luaL_error(L_, "invalid hook option %s", _str.data()); } return _op; } diff --git a/src/lane.cpp b/src/lane.cpp index 9f68c91..6e6130c 100644 --- a/src/lane.cpp +++ b/src/lane.cpp @@ -1018,7 +1018,7 @@ namespace { } // namespace // contains keys: { __close, __gc, __index, kCachedError, kCachedTostring, cancel, get_threadname, join } -void Lane::PushMetatable(lua_State* L_) +void Lane::PushMetatable(lua_State* const L_) { STACK_CHECK_START_REL(L_, 0); if (luaL_newmetatable(L_, kLaneMetatableName.data())) { // L_: mt @@ -1039,7 +1039,7 @@ void Lane::PushMetatable(lua_State* L_) // ################################################################################################# -void Lane::pushStatusString(lua_State* L_) const +void Lane::pushStatusString(lua_State* const L_) const { std::string_view const _str{ threadStatusString() }; LUA_ASSERT(L_, !_str.empty()); -- cgit v1.2.3-55-g6feb