Commit 725c7cca authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

some fixes after github codeql-analysis

parent 248791e2
......@@ -140,7 +140,7 @@ ModbusRTU::mbErrCode MBTCPTestServer::readCoilStatus( ReadCoilMessage& query,
}
// Фомирование ответа:
ModbusData num = 0; // добавленное количество данных
size_t num = 0; // добавленное количество данных
size_t bcnt = numBytes(query.count);
for( ; num < bcnt; num++ )
......
......@@ -38,7 +38,7 @@ TEST_CASE("[REST API: conf]", "[restapi][configure]")
{
init_test();
std::string s = shm->apiRequest("/configure/get?2,Input5_S&params=iotype");
std::string s = shm->apiRequest("/configure/get?2,Input5_S&params=iotype");
Poco::JSON::Parser parser;
auto result = parser.parse(s);
......
......@@ -3167,14 +3167,15 @@ namespace uniset
func = fnSetDateTime;
time_t tm = time(0);
struct tm* tms = localtime(&tm);
hour = tms->tm_hour;
min = tms->tm_min;
sec = tms->tm_sec;
day = tms->tm_mday;
mon = tms->tm_mon + 1;
year = tms->tm_year;
century = ( tms->tm_year + 1900 >= 2000 ) ? 20 : 19;
std::tm tms;
gmtime_r(&tm, &tms);
hour = tms.tm_hour;
min = tms.tm_min;
sec = tms.tm_sec;
day = tms.tm_mday;
mon = tms.tm_mon + 1;
year = tms.tm_year;
century = ( tms.tm_year + 1900 >= 2000 ) ? 20 : 19;
}
// -------------------------------------------------------------------------
SetDateTimeRetMessage::SetDateTimeRetMessage( const SetDateTimeMessage& query )
......
......@@ -503,21 +503,23 @@ bool uniset::check_filter( UniXML::iterator& it, const std::string& f_prop, cons
// ------------------------------------------------------------------------------------------
string uniset::timeToString(time_t tm, const std::string& brk ) noexcept
{
struct tm* tms = localtime(&tm);
std::tm tms;
gmtime_r(&tm, &tms);
ostringstream time;
time << std::setw(2) << std::setfill('0') << tms->tm_hour << brk;
time << std::setw(2) << std::setfill('0') << tms->tm_min << brk;
time << std::setw(2) << std::setfill('0') << tms->tm_sec;
time << std::setw(2) << std::setfill('0') << tms.tm_hour << brk;
time << std::setw(2) << std::setfill('0') << tms.tm_min << brk;
time << std::setw(2) << std::setfill('0') << tms.tm_sec;
return time.str();
}
string uniset::dateToString(time_t tm, const std::string& brk ) noexcept
{
struct tm* tms = localtime(&tm);
std::tm tms;
gmtime_r(&tm, &tms);
ostringstream date;
date << std::setw(4) << std::setfill('0') << tms->tm_year + 1900 << brk;
date << std::setw(2) << std::setfill('0') << tms->tm_mon + 1 << brk;
date << std::setw(2) << std::setfill('0') << tms->tm_mday;
date << std::setw(4) << std::setfill('0') << tms.tm_year + 1900 << brk;
date << std::setw(2) << std::setfill('0') << tms.tm_mon + 1 << brk;
date << std::setw(2) << std::setfill('0') << tms.tm_mday;
return date.str();
}
......
......@@ -210,7 +210,8 @@ std::ostream& DebugStream::printDate(Debug::type t, char brk) noexcept
uniset::ios_fmt_restorer ifs(*this);
std::time_t tv = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm tms = *std::localtime(&tv);
std::tm tms;
gmtime_r(&tv, &tms);
#if __GNUC__ >= 5
std::ostringstream fmt;
......@@ -233,7 +234,8 @@ std::ostream& DebugStream::printTime(Debug::type t, char brk) noexcept
uniset::ios_fmt_restorer ifs(*this);
timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0);
std::tm tms = *std::localtime(&tv.tv_sec);
std::tm tms;
gmtime_r(&tv.tv_sec, &tms);
#if __GNUC__ >= 5
std::ostringstream fmt;
......@@ -263,7 +265,8 @@ std::ostream& DebugStream::printDateTime(Debug::type t) noexcept
uniset::ios_fmt_restorer ifs(*this);
timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0);
std::tm tms = *std::localtime(&tv.tv_sec);
std::tm tms;
gmtime_r(&tv.tv_sec, &tms);
#if __GNUC__ >= 5
*this << std::put_time(&tms, "%Od/%Om/%Y %OH:%OM:%OS");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment