Skip to content

Commit

Permalink
Fix LGTM localtime function warnings (sonic-net#707)
Browse files Browse the repository at this point in the history
Signed-off-by: kcudnik <[email protected]>
  • Loading branch information
kcudnik authored Nov 16, 2020
1 parent 9fb6fe9 commit c847733
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
15 changes: 6 additions & 9 deletions lib/src/Recorder.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#include "swss/table.h"
#include <vector>
#include <fstream>

#include "Recorder.h"

#include "meta/sai_serialize.h"
Expand All @@ -11,6 +7,8 @@
#include <inttypes.h>

#include <cstring>
#include <vector>
#include <fstream>

using namespace sairedis;
using namespace saimeta;
Expand Down Expand Up @@ -216,7 +214,10 @@ std::string Recorder::getTimestamp()

gettimeofday(&tv, NULL);

size_t size = strftime(buffer, 32, "%Y-%m-%d.%T.", localtime(&tv.tv_sec));
struct tm now;
localtime_r(&tv.tv_sec, &now);

size_t size = strftime(buffer, 32, "%Y-%m-%d.%T.", &now);

snprintf(&buffer[size], 32, "%06ld", tv.tv_usec);

Expand Down Expand Up @@ -283,7 +284,6 @@ void Recorder::recordQueryAttributeCapabilityResponse(
recordLine("Q|attribute_capability|" + sai_serialize_status(status) + "|" + joinFieldValues(arguments));
}


void Recorder::recordQueryAttributeEnumValuesCapability(
_In_ const std::string& key,
_In_ const std::vector<swss::FieldValueTuple>& arguments)
Expand Down Expand Up @@ -514,7 +514,6 @@ void Recorder::recordBulkGenericSet(
recordLine("S|" + key + joined);
}


void Recorder::recordBulkGenericSetResponse(
_In_ sai_status_t status,
_In_ uint32_t objectCount,
Expand Down Expand Up @@ -833,7 +832,6 @@ void Recorder::recordRemove( \
_X(ROUTE_ENTRY,route_entry); \
_X(NAT_ENTRY,nat_entry); \


REDIS_DECLARE_EVERY_ENTRY(DECLARE_RECORD_REMOVE_ENTRY)

#define DECLARE_RECORD_CREATE_ENTRY(OT,ot) \
Expand Down Expand Up @@ -940,7 +938,6 @@ void Recorder::recordQueryAttributeCapability(
recordQueryAttributeCapability(key, values);
}


void Recorder::recordQueryAttributeCapabilityResponse(
_In_ sai_status_t status,
_In_ sai_object_type_t objectType,
Expand Down
3 changes: 2 additions & 1 deletion saisdkdump/saisdkdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ int main(int argc, char **argv)
{
std::ostringstream strStream;
time_t t = time(NULL);
struct tm *now = localtime(&t);
struct tm local_tm;
struct tm *now = localtime_r(&t, &local_tm);
strStream << "/tmp/saisdkdump_" << now->tm_mday << "_" << now->tm_mon + 1 << "_" << now->tm_year + 1900 << "_" << now->tm_hour << "_" << now->tm_min << "_" << now->tm_sec;
fileName = strStream.str();
SWSS_LOG_INFO("The dump file is not specified, generated \"%s\" file name", fileName.c_str());
Expand Down
2 changes: 1 addition & 1 deletion syncd/PortMapParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <sstream>
#include <cstring>

// FIXME: introduce common config format for SONiC
// TODO: introduce common config format for SONiC
std::shared_ptr<PortMap> PortMapParser::parsePortMap(
_In_ const std::string& portMapFile)
{
Expand Down

0 comments on commit c847733

Please sign in to comment.