Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0ac617f
Add noexcept on non throwing methods identified by static analysis
mkoscumb Jun 26, 2023
fcc321e
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
mkoscumb Jun 26, 2023
1d9ee3e
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
mkoscumb Jun 26, 2023
7e3ca2e
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
mkoscumb Jun 26, 2023
a3177f2
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
mkoscumb Jun 28, 2023
3a1b79a
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
lalitb Aug 3, 2023
3cab212
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
lalitb Aug 15, 2023
d099b1f
Merge remote-tracking branch 'msft/main' into bhamehta/noexcept-takeo…
bmehta001 Jun 12, 2026
225ee96
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
bmehta001 Jun 17, 2026
2ac4ecc
LogSessionDataProvider: harden convertStrToLong (reset errno, reject …
bmehta001 Jun 17, 2026
c58c82e
LogSessionDataProvider: parse with strtoull to match uint64_t return …
bmehta001 Jun 18, 2026
39f6646
LogSessionDataProvider: mark remove_eol noexcept
bmehta001 Jun 18, 2026
f495b47
EventProperties: add noexcept move constructor and move assignment
bmehta001 Jun 18, 2026
e5419e3
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
bmehta001 Jun 19, 2026
51bd229
LogSessionDataProvider: fix %d format specifier for const char* names
bmehta001 Jun 22, 2026
3f452ca
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
bmehta001 Jun 29, 2026
7ae6f70
Merge branch 'main' into user/mkoscumb/AddNoexceptToNonThrowingMethods
bmehta001 Jul 1, 2026
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 @@ -836,7 +836,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 @@ -859,7 +859,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 @@ -872,7 +872,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 @@ -941,7 +941,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
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.
Resolved
/// <summary>
/// Gets the SDK unique identifier.
Expand Down
4 changes: 2 additions & 2 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 Down Expand Up @@ -153,7 +153,7 @@ 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.
Resolved
{
uint64_t res = 0ull;
char *endptr = nullptr;
Expand Down
6 changes: 3 additions & 3 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,7 +55,7 @@ namespace MAT_NS_BEGIN
std::string const m_cacheFilePath;
SessionStorageType m_storageType;
std::unique_ptr<LogSessionData> m_logSessionData;
uint64_t convertStrToLong(const std::string&);
uint64_t convertStrToLong(const std::string&) noexcept;
void writeFileContents(const std::string&, uint64_t, const std::string&);
void remove_eol(std::string& );
};
Expand Down
2 changes: 1 addition & 1 deletion lib/pal/desktop/NetworkDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ namespace MAT_NS_BEGIN
return true;
}

bool NetworkDetector::RegisterAndListen()
bool NetworkDetector::RegisterAndListen() noexcept
{
// ???
HRESULT hr = pNlm->QueryInterface(IID_IUnknown, (void**)&pSink);
Expand Down
2 changes: 1 addition & 1 deletion lib/pal/desktop/NetworkDetector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace MAT_NS_BEGIN
/// Register and listen to network state notifications
/// </summary>
/// <returns></returns>
bool RegisterAndListen();
bool RegisterAndListen() noexcept;

/// <summary>
/// Reset network state listener to uninitialized state
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 @@ -273,7 +273,7 @@ namespace testing {
return fname;
}

void LogMemUsage(const char* label)
void LogMemUsage(const char* label) noexcept
{
#ifdef DEBUG_PERF
#ifdef _WIN32
Expand All @@ -300,7 +300,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
2 changes: 1 addition & 1 deletion tests/functests/MultipleLogManagersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using namespace MAT;
class RequestHandler : public HttpServer::Callback
{
public:
RequestHandler(int id) : m_count(0), m_id(id){}
RequestHandler(int id) noexcept: m_count(0), m_id(id){}

int onHttpRequest(HttpServer::Request const& request, HttpServer::Response& /*response*/) override
{
Expand Down