Add noexcept on non-throwing methods identified by static analysis.#1179
Add noexcept on non-throwing methods identified by static analysis.#1179mkoscumb wants to merge 14 commits into
Conversation
|
@mkoscumb - Can this be merged? |
|
@mkoscumb - ping to merge this. |
…ver-1179 # Conflicts: # lib/offline/LogSessionDataProvider.hpp # lib/system/TelemetrySystemBase.hpp # tests/functests/MultipleLogManagersTests.cpp
|
Picking this up to get it merge-ready (the long gap left it conflicting against Resolved conflicts by merging
Validated on Windows (VS 2026 toolset, x64 Release): The PR is now mergeable. @lalitb's earlier approval is necessarily stale after the merge commit — a fresh review/approval is needed. Thanks @mkoscumb for the original change. |
There was a problem hiding this comment.
Pull request overview
This PR adds noexcept to methods and lambdas that static analysis identified as non-throwing, tightening exception guarantees across test utilities, internal helpers, and some SDK-facing code.
Changes:
- Annotated various utility and helper functions with
noexceptin declarations and definitions. - Added
noexceptto several small lambdas used in algorithms / predicates. - Updated session-data accessors and providers to reflect non-throwing behavior.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/common/MockIRuntimeConfig.hpp | Marks test mock static config accessor as noexcept. |
| tests/common/Common.hpp | Marks perf-logging helpers as noexcept. |
| tests/common/Common.cpp | Updates perf-logging helper definitions to noexcept. |
| lib/utils/Utils.hpp | Marks IsRunningInApp() as noexcept. |
| lib/utils/Utils.cpp | Updates IsRunningInApp() definition to noexcept. |
| lib/utils/StringUtils.hpp | Marks several string utilities / enum-to-string helpers as noexcept. |
| lib/utils/StringUtils.cpp | Updates corresponding definitions; adds noexcept to small transform lambdas. |
| lib/utils/annex_k.hpp | Marks several static bounds-check helpers as noexcept. |
| lib/system/TelemetrySystemBase.hpp | Marks default lifecycle lambdas as noexcept. |
| lib/offline/LogSessionDataProvider.hpp | Marks constructor / accessors / parser helper as noexcept. |
| lib/offline/LogSessionDataProvider.cpp | Updates definitions for GetLogSessionData() / convertStrToLong() to noexcept. |
| lib/include/public/LogSessionData.hpp | Marks a public accessor (getSessionFirstTime) as noexcept. |
| lib/api/LogSessionData.cpp | Updates implementation of getSessionFirstTime() to noexcept. |
| lib/api/LogManagerImpl.cpp | Adds noexcept to several small lambdas used as predicates. |
Comments suppressed due to low confidence (1)
lib/offline/LogSessionDataProvider.cpp:160
convertStrToLongcheckserrnoafterstrtollbut never resets it before the call, so a previously-seterrnocan cause false error handling. Also, parsing a negative value will currently wrap into a largeuint64_twithout being rejected.
uint64_t LogSessionDataProvider::convertStrToLong(const std::string& s) noexcept
{
uint64_t res = 0ull;
char *endptr = nullptr;
res = std::strtoll(s.c_str(), &endptr, 10);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…negatives) Addresses the Copilot low-confidence (suppressed) review note on convertStrToLong: - strtoll's errno was checked without being reset first, so a stale errno from an earlier call could trip false "conversion failed" handling. errno is now cleared before the call. - a negative input wrapped silently into a large uint64_t. The value is now parsed into a signed temp and rejected (returns 0 + warns) if negative. - the imprecise res==LONG_MAX overflow heuristic is replaced by a direct errno==ERANGE check plus an explicit no-conversion / trailing-character check. noexcept is preserved (no throwing operations). Pre-existing logic, folded in here since this PR already annotates the same function. Verified: NDK aarch64-linux-android23 -fsyntax-only clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…type Follow-up to the Copilot review on convertStrToLong: the function returns uint64_t but parsed via std::strtoll (signed long long), which constrains the accepted range to LLONG_MAX and mixes signed/unsigned. Switch to std::strtoull so parsing matches the return type and the full uint64_t range is accepted. strtoull silently wraps a leading '-', so negatives are now rejected explicitly (first non-space char check) before parsing, preserving the earlier negative-rejection behavior. noexcept preserved. Verified: NDK aarch64-linux-android23 -fsyntax-only clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
remove_eol only inspects and shrinks the string in place (empty(), operator[], length(), and erase() at a validated position) -- none of which allocate or throw -- so it is genuinely non-throwing. Extends this PR's noexcept coverage to the one remaining sibling helper in the session-data classes that is safely non-throwing (parse()/writeFileContents()/the std::string ctor allocate, so they correctly stay un-annotated). Verified NDK aarch64-linux-android23 -fsyntax-only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EventProperties is pimpl (single EventPropertiesStorage* m_storage) with a user-declared copy ctor/assign + virtual dtor, so the compiler generated no move operations -- every pass/return/vector-growth deep-copied the whole property map via `new EventPropertiesStorage(*copy.m_storage)`. Add O(1) noexcept move ctor + move assignment that transfer the storage pointer. The dtor is already null-safe (delete nullptr); copy-assignment is now also null-safe so a moved-from object can be reassigned. Backward-compatible API addition (the single-pointer layout is unchanged). Verified: NDK aarch64-linux-android23 -fsyntax-only clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
No description provided.