From 492aab20feb463888aa19d576d5b239868ab312e Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 23 Feb 2024 22:21:47 +0100 Subject: [PATCH] Fix compiler warnings --- src/client/imagefilters.cpp | 4 ++-- src/network/connection.h | 16 ++++++++-------- src/script/common/c_packer.cpp | 2 +- src/script/lua_api/l_minimap.cpp | 6 ------ src/unittest/test_datastructures.cpp | 2 +- src/util/string.h | 16 +++++++++++----- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/client/imagefilters.cpp b/src/client/imagefilters.cpp index 320af1fc8..55dedd09d 100644 --- a/src/client/imagefilters.cpp +++ b/src/client/imagefilters.cpp @@ -71,14 +71,14 @@ static void imageCleanTransparentWithInlining(video::IImage *src, u32 threshold) void *const src_data = src->getData(); const core::dimension2d dim = src->getDimension(); - auto get_pixel = [src, src_data, dim](u32 x, u32 y) -> video::SColor { + auto get_pixel = [=](u32 x, u32 y) -> video::SColor { if constexpr (IS_A8R8G8B8) { return reinterpret_cast(src_data)[y*dim.Width + x]; } else { return src->getPixel(x, y); } }; - auto set_pixel = [src, src_data, dim](u32 x, u32 y, video::SColor color) { + auto set_pixel = [=](u32 x, u32 y, video::SColor color) { if constexpr (IS_A8R8G8B8) { u32 *dest = &reinterpret_cast(src_data)[y*dim.Width + x]; *dest = color.color; diff --git a/src/network/connection.h b/src/network/connection.h index 5dc97441a..4c7c7a609 100644 --- a/src/network/connection.h +++ b/src/network/connection.h @@ -615,7 +615,7 @@ class Peer { u64 m_last_timeout_check; }; -class UDPPeer : public Peer +class UDPPeer final : public Peer { public: @@ -628,15 +628,15 @@ public: virtual ~UDPPeer() = default; void PutReliableSendCommand(ConnectionCommandPtr &c, - unsigned int max_packet_size); + unsigned int max_packet_size) override; - bool getAddress(MTProtocols type, Address& toset); + bool getAddress(MTProtocols type, Address& toset) override; - u16 getNextSplitSequenceNumber(u8 channel); - void setNextSplitSequenceNumber(u8 channel, u16 seqnum); + u16 getNextSplitSequenceNumber(u8 channel) override; + void setNextSplitSequenceNumber(u8 channel, u16 seqnum) override; SharedBuffer addSplitPacket(u8 channel, BufferedPacketPtr &toadd, - bool reliable); + bool reliable) override; bool isTimedOut(float timeout, std::string &reason) override; @@ -645,7 +645,7 @@ protected: Calculates avg_rtt and resend_timeout. rtt=-1 only recalculates resend_timeout */ - void reportRTT(float rtt); + void reportRTT(float rtt) override; void RunCommandQueues( unsigned int max_packet_size, @@ -657,7 +657,7 @@ protected: void setResendTimeout(float timeout) { MutexAutoLock lock(m_exclusive_access_mutex); resend_timeout = timeout; } - bool Ping(float dtime,SharedBuffer& data); + bool Ping(float dtime, SharedBuffer& data) override; Channel channels[CHANNEL_COUNT]; bool m_pending_disconnect = false; diff --git a/src/script/common/c_packer.cpp b/src/script/common/c_packer.cpp index 36b3f4dcc..c133e0ee2 100644 --- a/src/script/common/c_packer.cpp +++ b/src/script/common/c_packer.cpp @@ -630,7 +630,7 @@ void script_dump_packed(const PackedValue *val) printf("table(%d, %d)", i.uidata1, i.uidata2); break; case LUA_TFUNCTION: - printf("function(%lu byte)", i.sdata.size()); + printf("function(%d bytes)", (int)i.sdata.size()); break; case LUA_TUSERDATA: printf("userdata %s %p", i.sdata.c_str(), i.ptrdata); diff --git a/src/script/lua_api/l_minimap.cpp b/src/script/lua_api/l_minimap.cpp index 36384b201..fcaf89bbb 100644 --- a/src/script/lua_api/l_minimap.cpp +++ b/src/script/lua_api/l_minimap.cpp @@ -132,9 +132,6 @@ int LuaMinimap::l_show(lua_State *L) if (!g_settings->getBool("enable_minimap")) return 1; - Client *client = getClient(L); - assert(client); - LuaMinimap *ref = checkObject(L, 1); Minimap *m = getobject(ref); @@ -149,9 +146,6 @@ int LuaMinimap::l_show(lua_State *L) int LuaMinimap::l_hide(lua_State *L) { - Client *client = getClient(L); - assert(client); - LuaMinimap *ref = checkObject(L, 1); Minimap *m = getobject(ref); diff --git a/src/unittest/test_datastructures.cpp b/src/unittest/test_datastructures.cpp index cd3755a1f..0bf892353 100644 --- a/src/unittest/test_datastructures.cpp +++ b/src/unittest/test_datastructures.cpp @@ -104,7 +104,7 @@ void TestDataStructures::testMap1() UASSERT(t0.deleted); UASSERT(!t1.copied); UASSERT(!t1.deleted); - if (once |= 1) + if ((once |= 1)) break; } UASSERT(once); diff --git a/src/util/string.h b/src/util/string.h index 01ec73481..36c374bdf 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -43,13 +43,19 @@ class Translations; ( (unsigned int)(x) <= 0x7e)) // Checks whether a value is in a Unicode private use area -#define IS_PRIVATE_USE_CHAR(x) \ - (((wchar_t)(x) >= 0xE000 && \ - (wchar_t)(x) <= 0xF8FF) || \ - ((wchar_t)(x) >= 0xF0000 && \ +#define IS_PRIVATE_USE_CHAR16(x) \ + ((wchar_t)(x) >= 0xE000 && \ + (wchar_t)(x) <= 0xF8FF) +#define IS_PRIVATE_USE_CHAR32(x) \ + (((wchar_t)(x) >= 0xF0000 && \ (wchar_t)(x) <= 0xFFFFD) || \ ((wchar_t)(x) >= 0x100000 && \ - (wchar_t)(x) <= 0x10FFFD)) \ + (wchar_t)(x) <= 0x10FFFD)) +#if WCHAR_MAX > 0xFFFF +#define IS_PRIVATE_USE_CHAR(x) (IS_PRIVATE_USE_CHAR16(x) || IS_PRIVATE_USE_CHAR32(x)) +#else +#define IS_PRIVATE_USE_CHAR(x) IS_PRIVATE_USE_CHAR16(x) +#endif // Checks whether a byte is an inner byte for an utf-8 multibyte sequence #define IS_UTF8_MULTB_INNER(x) \