From 1ed49e74877318bf88a52f33bc98e83152b07f79 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Fri, 10 Jan 2025 19:55:14 -0500 Subject: [PATCH] refactor: replace SInt16 with int16_t --- src/lib/client/HelloBack.cpp | 4 ++-- src/lib/client/HelloBack.h | 8 ++++---- src/lib/client/ServerProxy.cpp | 8 ++++---- src/lib/common/basic_types.h | 1 - src/lib/deskflow/protocol_types.h | 4 ++-- src/lib/platform/MSWindowsHook.cpp | 2 +- src/lib/server/ClientProxy1_0.cpp | 2 +- src/lib/server/ClientProxyUnknown.cpp | 2 +- src/test/unittests/client/HelloBackTests.cpp | 6 +++--- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/lib/client/HelloBack.cpp b/src/lib/client/HelloBack.cpp index e93c49b33..c975f1f6d 100644 --- a/src/lib/client/HelloBack.cpp +++ b/src/lib/client/HelloBack.cpp @@ -36,8 +36,8 @@ void HelloBack::Deps::incompatible(int major, int minor) void HelloBack::handleHello(deskflow::IStream *stream, const std::string &clientName) const { - SInt16 serverMajor; - SInt16 serverMinor; + int16_t serverMajor; + int16_t serverMinor; // as luck would have it, both "Synergy" and "Barrier" are 7 chars, // so we eat 7 chars and then test for either protocol name. diff --git a/src/lib/client/HelloBack.h b/src/lib/client/HelloBack.h index 88e576f2b..2c7679446 100644 --- a/src/lib/client/HelloBack.h +++ b/src/lib/client/HelloBack.h @@ -45,8 +45,8 @@ public: }; explicit HelloBack( - std::shared_ptr deps, const SInt16 majorVersion = kProtocolMajorVersion, - const SInt16 minorVersion = kProtocolMinorVersion + std::shared_ptr deps, const int16_t majorVersion = kProtocolMajorVersion, + const int16_t minorVersion = kProtocolMinorVersion ) : m_deps(deps), m_majorVersion(majorVersion), @@ -63,8 +63,8 @@ private: bool shouldDowngrade(int major, int minor) const; std::shared_ptr m_deps; - SInt16 m_majorVersion; - SInt16 m_minorVersion; + int16_t m_majorVersion; + int16_t m_minorVersion; }; } // namespace deskflow::client diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index 9c9fbaac3..bda736b60 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -513,7 +513,7 @@ KeyModifierMask ServerProxy::translateModifierMask(KeyModifierMask mask) const void ServerProxy::enter() { // parse - SInt16 x, y; + int16_t x, y; UInt16 mask; UInt32 seqNum; ProtocolUtil::readf(m_stream, kMsgCEnter + 4, &x, &y, &seqNum, &mask); @@ -678,7 +678,7 @@ void ServerProxy::mouseMove() { // parse bool ignore; - SInt16 x, y; + int16_t x, y; ProtocolUtil::readf(m_stream, kMsgDMouseMove + 4, &x, &y); // note if we should ignore the move @@ -710,7 +710,7 @@ void ServerProxy::mouseRelativeMove() { // parse bool ignore; - SInt16 dx, dy; + int16_t dx, dy; ProtocolUtil::readf(m_stream, kMsgDMouseRelMove + 4, &dx, &dy); // note if we should ignore the move @@ -741,7 +741,7 @@ void ServerProxy::mouseWheel() flushCompressedMouse(); // parse - SInt16 xDelta, yDelta; + int16_t xDelta, yDelta; ProtocolUtil::readf(m_stream, kMsgDMouseWheel + 4, &xDelta, &yDelta); LOG((CLOG_DEBUG2 "recv mouse wheel %+d,%+d", xDelta, yDelta)); diff --git a/src/lib/common/basic_types.h b/src/lib/common/basic_types.h index 2087befa7..e69055034 100644 --- a/src/lib/common/basic_types.h +++ b/src/lib/common/basic_types.h @@ -84,7 +84,6 @@ #if defined(__APPLE__) #include #else -using SInt16 = signed TYPE_OF_SIZE_2; using SInt32 = signed TYPE_OF_SIZE_4; using UInt16 = unsigned TYPE_OF_SIZE_2; using UInt32 = unsigned TYPE_OF_SIZE_4; diff --git a/src/lib/deskflow/protocol_types.h b/src/lib/deskflow/protocol_types.h index 40d1f2cdd..c4b464c18 100644 --- a/src/lib/deskflow/protocol_types.h +++ b/src/lib/deskflow/protocol_types.h @@ -34,8 +34,8 @@ // 1.7 adds security input notifications // 1.8 adds language synchronization functionality // NOTE: with new version, deskflow minor version should increment -static const SInt16 kProtocolMajorVersion = 1; -static const SInt16 kProtocolMinorVersion = 8; +static const int16_t kProtocolMajorVersion = 1; +static const int16_t kProtocolMinorVersion = 8; // default contact port number static const UInt16 kDefaultPort = 24800; diff --git a/src/lib/platform/MSWindowsHook.cpp b/src/lib/platform/MSWindowsHook.cpp index b51b1a734..3cd4007f6 100644 --- a/src/lib/platform/MSWindowsHook.cpp +++ b/src/lib/platform/MSWindowsHook.cpp @@ -587,7 +587,7 @@ static LRESULT CALLBACK mouseLLHook(int code, WPARAM wParam, LPARAM lParam) SInt32 x = static_cast(info->pt.x); SInt32 y = static_cast(info->pt.y); - SInt32 w = static_cast(HIWORD(info->mouseData)); + SInt32 w = static_cast(HIWORD(info->mouseData)); // handle the message if (mouseHookHandler(wParam, x, y, w)) { diff --git a/src/lib/server/ClientProxy1_0.cpp b/src/lib/server/ClientProxy1_0.cpp index 7e6841afd..20491a13c 100644 --- a/src/lib/server/ClientProxy1_0.cpp +++ b/src/lib/server/ClientProxy1_0.cpp @@ -390,7 +390,7 @@ void ClientProxy1_0::setOptions(const OptionsList &options) bool ClientProxy1_0::recvInfo() { // parse the message - SInt16 x, y, w, h, dummy1, mx, my; + int16_t x, y, w, h, dummy1, mx, my; if (!ProtocolUtil::readf(getStream(), kMsgDInfo + 4, &x, &y, &w, &h, &dummy1, &mx, &my)) { return false; } diff --git a/src/lib/server/ClientProxyUnknown.cpp b/src/lib/server/ClientProxyUnknown.cpp index f4dc3f1b5..237ef997f 100644 --- a/src/lib/server/ClientProxyUnknown.cpp +++ b/src/lib/server/ClientProxyUnknown.cpp @@ -231,7 +231,7 @@ void ClientProxyUnknown::handleData(const Event &, void *) } // parse the reply to hello - SInt16 major, minor; + int16_t major, minor; std::string protocolName; if (!ProtocolUtil::readf(m_stream, kMsgHelloBack, &protocolName, &major, &minor, &name)) { throw XBadClient(); diff --git a/src/test/unittests/client/HelloBackTests.cpp b/src/test/unittests/client/HelloBackTests.cpp index 1e8ed9a09..7cd8a6af4 100644 --- a/src/test/unittests/client/HelloBackTests.cpp +++ b/src/test/unittests/client/HelloBackTests.cpp @@ -30,7 +30,7 @@ public: MOCK_METHOD(void, incompatible, (int major, int minor), (override)); }; -void intTo2ByteBuf(SInt16 value, std::array &buf) +void intTo2ByteBuf(int16_t value, std::array &buf) { buf[0] = static_cast((value >> 8) & 0xFF); // MSB buf[1] = static_cast(value & 0xFF); // LSB @@ -55,7 +55,7 @@ std::string printAsHex(const char *buffer, size_t size) } void setupMockHelloRead( - MockStream &stream, const std::string &protocolName, const SInt16 majorVersion, const SInt16 minorVersion + MockStream &stream, const std::string &protocolName, const int16_t majorVersion, const int16_t minorVersion ) { @@ -89,7 +89,7 @@ void setupMockHelloRead( } void setupMockHelloBackWrite( - MockStream &stream, const std::string &protocolName, const SInt16 majorVersion, const SInt16 minorVersion, + MockStream &stream, const std::string &protocolName, const int16_t majorVersion, const int16_t minorVersion, const std::string &name ) {