Skip to content

Commit

Permalink
SYNERGY-956 - Resolve code scanning issues (#7006)
Browse files Browse the repository at this point in the history
* SYNERGY-956 - Resolve code scanning issues

* SYNERGY-956 - Update changelog

* SYNERGY-956 - Platform based localtime

* SYNERGY-956 - Fix argument order

Co-authored-by: SerhiiGadzhilov <71632867+SerhiiGadzhilov@users.noreply.github.com>
  • Loading branch information
igor-sikachyna and SerhiiGadzhilov committed May 26, 2021
1 parent ab346d4 commit c7fd0a8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v1.14.1-snapshot
===========
Bug fixes:
- #7016 Fix script that generates version number
- #7006 Resolve code scanning issues

Enhancements:

Expand Down
10 changes: 7 additions & 3 deletions src/lib/base/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,17 @@ Log::print(const char* file, int line, const char* fmt, ...)
// do not prefix time and file for kPRINT (CLOG_PRINT)
if (priority != kPRINT) {

struct tm *tm;
struct tm tm;
static const int timestamp_size = 50;
char timestamp[timestamp_size];
time_t t;
time(&t);
tm = localtime(&t);
snprintf(timestamp, timestamp_size, "%04i-%02i-%02iT%02i:%02i:%02i", tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
#if WINAPI_MSWINDOWS
localtime_s(&tm, &t);
#else
localtime_r(&t, &tm);
#endif
snprintf(timestamp, timestamp_size, "%04i-%02i-%02iT%02i:%02i:%02i", tm.tm_year + 1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);

// square brackets, spaces, comma and null terminator take about 10
int size = 10;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/InputFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ InputFilter::KeyboardBroadcastAction::format() const
}
else {
return synergy::string::sprintf("%s(%s,%.*s)", s_name, s_mode[m_mode],
m_screens.size() - 2,
static_cast<int>(m_screens.size() >= 2 ? m_screens.size() - 2 : 0),
m_screens.c_str() + 1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/unittests/synergy/ProtocolUtilTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ MATCHER_P(EqVoidPointeeInt32, expected, "")
MATCHER_P(EqVoidVectorInt1byte, expected, "")
{
bool Result = true;
const UInt8* Actual = (static_cast<const UInt8*>(arg)) + sizeof (UInt32);
const UInt8* Actual = (static_cast<const UInt8*>(arg)) + 4;
const size_t Size = *(Actual - 1);

if (Size == expected.size()){
Expand All @@ -77,7 +77,7 @@ MATCHER_P(EqVoidVectorInt1byte, expected, "")
MATCHER_P(EqVoidVectorInt2bytes, expected, "")
{
bool Result = true;
const UInt16* Actual = (static_cast<const UInt16*>(arg)) + sizeof (UInt16);
const UInt16* Actual = (static_cast<const UInt16*>(arg)) + 2;
const size_t Size = *(Actual - 1) >> 8;

if (Size == expected.size()){
Expand Down

0 comments on commit c7fd0a8

Please sign in to comment.