Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 24, 2025

Summary of the Pull Request

Addresses code review feedback on PR #13971 by fixing lambda capture lists and improving exception handling in GetProcessorFeatures() and GetSchemaVersion().

PR Checklist

  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Lambda capture fix: Changed [&] to [] in both functions. The lambdas don't capture any variables from the enclosing scope - they only modify static variables which are directly accessible without capture.

Exception handling improvement: Changed static cached values from direct types to std::optional<T>:

  • std::vector<std::string>std::optional<std::vector<std::string>>
  • std::pair<uint32_t, uint32_t>std::optional<std::pair<uint32_t, uint32_t>>

Return statements now use .value() to explicitly unwrap the optional. This makes initialization state unambiguous: if std::call_once completes successfully, the optional is set; if it throws, execution never reaches the return statement.

static std::optional<std::vector<std::string>> g_processorFeatures;
static std::once_flag flag;
std::call_once(flag, []() {
    // ... initialization code that may throw ...
    g_processorFeatures = std::move(response.Response.ProcessorFeatures);
});
return g_processorFeatures.value();  // Only reached if initialization succeeded

Validation Steps Performed

  • Code formatting validated with clang-format
  • Code review completed with no issues
  • CodeQL security scan passed

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve logging of HCS helper utilities in debug builds Fix lambda captures and exception handling in HCS static initialization Dec 24, 2025
Copilot AI requested a review from benhillis December 24, 2025 00:26
@benhillis benhillis closed this Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants