Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/api/LogManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ namespace MAT_NS_BEGIN
return;
}

auto itDataInspector = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&dataInspector](const std::shared_ptr<IDataInspector>& currentInspector)
auto itDataInspector = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&dataInspector](const std::shared_ptr<IDataInspector>& currentInspector) noexcept
{
return strcmp(dataInspector->GetName(), currentInspector->GetName()) == 0;
});
Expand All @@ -862,7 +862,7 @@ namespace MAT_NS_BEGIN
void LogManagerImpl::RemoveDataInspector(const std::string& name)
{
LOCKGUARD(m_dataInspectorGuard);
auto itDataInspector = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&name](const std::shared_ptr<IDataInspector>& inspector){
auto itDataInspector = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&name](const std::shared_ptr<IDataInspector>& inspector) noexcept {
return strcmp(inspector->GetName(), name.c_str()) == 0;
});

Expand All @@ -875,7 +875,7 @@ namespace MAT_NS_BEGIN
std::shared_ptr<IDataInspector> LogManagerImpl::GetDataInspector(const std::string& name) noexcept
{
LOCKGUARD(m_dataInspectorGuard);
auto it = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&name](const std::shared_ptr<IDataInspector>& inspector){
auto it = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&name](const std::shared_ptr<IDataInspector>& inspector) noexcept{
return strcmp(inspector->GetName(), name.c_str()) == 0;
});

Expand Down Expand Up @@ -944,7 +944,7 @@ namespace MAT_NS_BEGIN
if (m_pause_state != PauseState::Pausing) {
return;
}
m_pause_cv.wait(lock, [this]() -> bool {
m_pause_cv.wait(lock, [this]() noexcept -> bool {
return m_pause_state != PauseState::Pausing;
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/api/LogSessionData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace std;

namespace MAT_NS_BEGIN {

uint64_t LogSessionData::getSessionFirstTime() const
uint64_t LogSessionData::getSessionFirstTime() const noexcept
{
return m_sessionFirstTimeLaunch;
}
Expand Down
12 changes: 12 additions & 0 deletions lib/include/public/EventProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ namespace MAT_NS_BEGIN
/// </summary>
EventProperties& operator=(EventProperties const& copy);

/// <summary>
/// The EventProperties move constructor. Transfers ownership of the
/// underlying storage (O(1)); the moved-from object is left empty and is
/// only valid to destroy or reassign.
/// </summary>
EventProperties(EventProperties&& move) noexcept;

/// <summary>
/// The EventProperties move-assignment operator.
/// </summary>
EventProperties& operator=(EventProperties&& move) noexcept;

/// <summary>
/// Constructs an EventProperties object from a map of string to EventProperty.<br>
/// You must supply a non-empty name whenever you supply any custom properties for the event via <b>EventProperties</b>.
Expand Down
2 changes: 1 addition & 1 deletion lib/include/public/LogSessionData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace MAT_NS_BEGIN
/// Gets the time that this session began.
/// </summary>
/// <returns>A 64-bit integer that contains the time.</returns>
uint64_t getSessionFirstTime() const;
uint64_t getSessionFirstTime() const noexcept;

Comment thread
bmehta001 marked this conversation as resolved.
/// <summary>
/// Gets the SDK unique identifier.
Expand Down
41 changes: 24 additions & 17 deletions lib/offline/LogSessionDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace MAT_NS_BEGIN
}
}

LogSessionData* LogSessionDataProvider::GetLogSessionData()
LogSessionData* LogSessionDataProvider::GetLogSessionData() noexcept
{
return m_logSessionData.get();
}
Expand All @@ -69,7 +69,7 @@ namespace MAT_NS_BEGIN
sessionSDKUid = PAL::generateUuidString();
if (!m_offlineStorage->StoreSetting(sessionFirstLaunchTimeName, std::to_string(sessionFirstTimeLaunch)))
{
LOG_WARN("Unable to save session analytics to DB for %d", sessionFirstLaunchTimeName);
LOG_WARN("Unable to save session analytics to DB for %s", sessionFirstLaunchTimeName);
}
if (!m_offlineStorage->StoreSetting(sessionSdkUidName, sessionSDKUid)) {
LOG_WARN("Unable to save session analytics to DB for %s", sessionSDKUid.c_str());
Expand All @@ -87,11 +87,11 @@ namespace MAT_NS_BEGIN
}
if (!m_offlineStorage->DeleteSetting(sessionFirstLaunchTimeName))
{
LOG_WARN("Unable to delete session analytics from DB for %d", sessionFirstLaunchTimeName);
LOG_WARN("Unable to delete session analytics from DB for %s", sessionFirstLaunchTimeName);
}
if (!m_offlineStorage->DeleteSetting(sessionSdkUidName))
{
LOG_WARN("Unable to delete session analytics from DB for %d", sessionSdkUidName);
LOG_WARN("Unable to delete session analytics from DB for %s", sessionSdkUidName);
}
}

Expand Down Expand Up @@ -153,25 +153,32 @@ namespace MAT_NS_BEGIN
return true;
}

uint64_t LogSessionDataProvider::convertStrToLong(const std::string& s)
uint64_t LogSessionDataProvider::convertStrToLong(const std::string& s) noexcept
Comment thread
bmehta001 marked this conversation as resolved.
{
uint64_t res = 0ull;
char *endptr = nullptr;
res = std::strtoll(s.c_str(), &endptr, 10);
if (errno == ERANGE && (res == LONG_MAX || res == 0 ))
// strtoull silently wraps a leading '-' into a large value, so reject
// negative input explicitly before parsing.
size_t firstNonSpace = s.find_first_not_of(" \t\n\r\f\v");
if (firstNonSpace != std::string::npos && s[firstNonSpace] == '-')
{
LOG_WARN ("Converted value falls out of uint64_t range.");
res = 0;
}
else if ( 0 != errno && 0 == res )
LOG_WARN ("Converted value is negative; rejecting.");
return 0;
}
errno = 0;
unsigned long long parsed = std::strtoull(s.c_str(), &endptr, 10);
if (errno == ERANGE)
{
LOG_WARN("Conversion cannot be performed.");
LOG_WARN ("Converted value falls out of range.");
Comment thread
bmehta001 marked this conversation as resolved.
}
else if (std::strlen(endptr) > 0)
else if (endptr == s.c_str() || std::strlen(endptr) > 0)
{
LOG_WARN ("Conversion cannot be performed. Alphanumeric characters present");
res = 0;
}
LOG_WARN ("Conversion cannot be performed.");
}
else
{
res = static_cast<uint64_t>(parsed);
}
Comment thread
bmehta001 marked this conversation as resolved.
return res;
}

Expand All @@ -193,7 +200,7 @@ namespace MAT_NS_BEGIN
}
}

void LogSessionDataProvider::remove_eol(std::string& result)
void LogSessionDataProvider::remove_eol(std::string& result) noexcept
{
if (!result.empty() && result[result.length() - 1] == '\n')
{
Expand Down
8 changes: 4 additions & 4 deletions lib/offline/LogSessionDataProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace MAT_NS_BEGIN
{
public:
LogSessionDataProvider(
IOfflineStorage* offlineStorage)
IOfflineStorage* offlineStorage) noexcept
:
m_offlineStorage(offlineStorage),
m_storageType(SessionStorageType::DatabaseStore),
Expand All @@ -41,7 +41,7 @@ namespace MAT_NS_BEGIN
void CreateLogSessionData();
void ResetLogSessionData();
void DeleteLogSessionData();
LogSessionData *GetLogSessionData();
LogSessionData *GetLogSessionData() noexcept;

protected:
void CreateLogSessionDataFromFile();
Expand All @@ -55,9 +55,9 @@ namespace MAT_NS_BEGIN
std::string const m_cacheFilePath;
SessionStorageType m_storageType;
std::unique_ptr<LogSessionData> m_logSessionData;
static uint64_t convertStrToLong(const std::string&);
static uint64_t convertStrToLong(const std::string&) noexcept;
Comment thread
bmehta001 marked this conversation as resolved.
static void writeFileContents(const std::string&, uint64_t, const std::string&);
void remove_eol(std::string& );
void remove_eol(std::string& ) noexcept;
};
}
MAT_NS_END
Expand Down
27 changes: 26 additions & 1 deletion lib/system/EventProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,33 @@ namespace MAT_NS_BEGIN {

EventProperties& EventProperties::operator=(EventProperties const& copy)
{
*m_storage = *copy.m_storage;
// m_storage may be null if this object was moved-from; reallocate then.
if (m_storage == nullptr)
{
m_storage = new EventPropertiesStorage(*copy.m_storage);
}
else
{
*m_storage = *copy.m_storage;
}

return *this;
}

EventProperties::EventProperties(EventProperties&& move) noexcept
: m_storage(move.m_storage)
{
move.m_storage = nullptr;
}

EventProperties& EventProperties::operator=(EventProperties&& move) noexcept
{
if (this != &move)
{
delete m_storage;
m_storage = move.m_storage;
move.m_storage = nullptr;
}
return *this;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/system/TelemetrySystemBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ namespace MAT_NS_BEGIN {
m_isPaused(false),
stats(*this, taskDispatcher)
{
onStart = []() { return true; };
onStop = []() { return true; };
onPause = []() { return true; };
onResume = []() { return true; };
onCleanup = []() { return true; };
onStart = []() noexcept { return true; };
onStop = []() noexcept { return true; };
onPause = []() noexcept { return true; };
onResume = []() noexcept { return true; };
onCleanup = []() noexcept { return true; };
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions lib/utils/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace MAT_NS_BEGIN
}
}

bool StringUtils::AreAllCharactersAllowlisted(const string& stringToTest, const string& allowlist)
bool StringUtils::AreAllCharactersAllowlisted(const string& stringToTest, const string& allowlist) noexcept
{
return (stringToTest.find_first_not_of(allowlist) == string::npos);
}
Expand Down Expand Up @@ -132,15 +132,15 @@ namespace MAT_NS_BEGIN
{
std::string result = str;
std::transform(str.begin(), str.end(), result.begin(),
[](unsigned char c) { return (char)::tolower(c); });
[](unsigned char c) noexcept { return (char)::tolower(c); });
return result;
}

std::string toUpper(const std::string& str)
{
std::string result = str;
std::transform(str.begin(), str.end(), result.begin(),
[](unsigned char c) { return (char)::toupper(c); });
[](unsigned char c) noexcept { return (char)::toupper(c); });
return result;
}

Expand All @@ -158,7 +158,7 @@ namespace MAT_NS_BEGIN
return str;
}

const char* priorityToStr(EventPriority priority)
const char* priorityToStr(EventPriority priority) noexcept
{
switch (priority)
{
Expand All @@ -185,7 +185,7 @@ namespace MAT_NS_BEGIN
}
}

const char* latencyToStr(EventLatency latency)
const char* latencyToStr(EventLatency latency) noexcept
{
switch (latency)
{
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/StringUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace MAT_NS_BEGIN
namespace StringUtils
{
void SplitString(const std::string& s, const char separator, std::vector<std::string>& parts);
bool AreAllCharactersAllowlisted(const std::string& stringToTest, const std::string& allowlist);
bool AreAllCharactersAllowlisted(const std::string& stringToTest, const std::string& allowlist) noexcept;
}

std::string toString(char const* value);
Expand All @@ -44,9 +44,9 @@ namespace MAT_NS_BEGIN

std::string sanitizeIdentifier(const std::string& str);

const char* priorityToStr(EventPriority priority);
const char* priorityToStr(EventPriority priority) noexcept;

const char* latencyToStr(EventLatency latency);
const char* latencyToStr(EventLatency latency) noexcept;

bool replace(std::string& str, const std::string& from, const std::string& to);

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace MAT_NS_BEGIN {
#endif
}

bool IsRunningInApp()
bool IsRunningInApp() noexcept
{
#ifdef _WINRT_DLL // Win 10 UWP
typedef LONG (*LPFN_GPFN)(UINT32*, PWSTR);
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace MAT_NS_BEGIN {
long GetCurrentProcessId();

/* Detects if current process is running in a packaged app*/
bool IsRunningInApp();
bool IsRunningInApp() noexcept;

std::string GetTempDirectory();
std::string GetAppLocalTempDirectory();
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/annex_k.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace MAT_NS_BEGIN
class BoundCheckFunctions
{
private:
static bool oneds_buffer_region_overlap(const char *buffer1, size_t buffer1_len, const char *buffer2, size_t buffer2_len)
static bool oneds_buffer_region_overlap(const char *buffer1, size_t buffer1_len, const char *buffer2, size_t buffer2_len) noexcept
{
if (buffer2 >= buffer1)
{
Expand All @@ -70,7 +70,7 @@ static bool oneds_buffer_region_overlap(const char *buffer1, size_t buffer1_len,
// - returns zero if str is a null pointer
// - returns strsz if the null character was not found in the first strsz bytes of str.

static size_t oneds_strnlen_s(const char *str, size_t strsz)
static size_t oneds_strnlen_s(const char *str, size_t strsz) noexcept
{
if ( str == NULL)
{
Expand All @@ -89,7 +89,7 @@ static size_t oneds_strnlen_s(const char *str, size_t strsz)
// - count is greater than RSIZE_MAX
// - count is greater or equal destsz, but destsz is less or equal strnlen_s(src, count), in other words, truncation would occur
// - overlap would occur between the source and the destination strings
static errno_t oneds_strncpy_s(char * restrict dest, rsize_t destsz, const char *restrict src, rsize_t count)
static errno_t oneds_strncpy_s(char * restrict dest, rsize_t destsz, const char *restrict src, rsize_t count) noexcept
{
#if (defined __STDC_LIB_EXT1__) || ( defined _MSC_VER)
return strncpy_s(dest, destsz, src, count);
Expand Down Expand Up @@ -148,7 +148,7 @@ static errno_t oneds_strncpy_s(char * restrict dest, rsize_t destsz, const char
// (if both dest and destsz are valid))

static errno_t oneds_memcpy_s( void *restrict dest, rsize_t destsz,
const void *restrict src, rsize_t count )
const void *restrict src, rsize_t count ) noexcept
{
#if (defined __STDC_LIB_EXT1__) || ( defined _MSC_VER)
return memcpy_s(dest, destsz, src, count);
Expand Down
4 changes: 2 additions & 2 deletions tests/common/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ namespace testing {
return fname;
}

void LogMemUsage(const char* label)
void LogMemUsage(const char* label) noexcept
{
#ifdef DEBUG_PERF
#ifdef _WIN32
Expand All @@ -295,7 +295,7 @@ namespace testing {
#endif
}

void LogCpuUsage(const char* label)
void LogCpuUsage(const char* label) noexcept
{
#ifdef DEBUG_PERF
static int64_t lastTime = GetUptimeMs();
Expand Down
4 changes: 2 additions & 2 deletions tests/common/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ namespace testing {
LogMemUsage(label); \
LogCpuUsage(label);

void LogMemUsage(const char* label);
void LogMemUsage(const char* label) noexcept;

void LogCpuUsage(const char* label);
void LogCpuUsage(const char* label) noexcept;
void InflateVector(std::vector<uint8_t> &in, std::vector<uint8_t> &out, bool isGzip = false);

} // namespace testing
Expand Down
2 changes: 1 addition & 1 deletion tests/common/MockIRuntimeConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace testing {
class MockIRuntimeConfig : public MAT::RuntimeConfig_Default /* MAT::IRuntimeConfig */ {

protected:
std::unique_ptr<ILogConfiguration>& GetStaticConfig()
std::unique_ptr<ILogConfiguration>& GetStaticConfig() noexcept
{
static std::unique_ptr<ILogConfiguration> staticConfig;
return staticConfig;
Expand Down
Loading