Create LogMonitorAPI and replace ETW EventRecord Callback - #2
Draft
iankingori wants to merge 2 commits into
Draft
iankingori wants to merge 2 commits into
iankingori wants to merge 2 commits into
Conversation
iankingori
marked this pull request as draft
June 20, 2025 07:08
Comment on lines
+60
to
+75
| switch (source->Type) | ||
| { | ||
| case LogSourceType::ETW: | ||
| { | ||
| std::shared_ptr<SourceETW> sourceETW = | ||
| std::reinterpret_pointer_cast<SourceETW>(source); | ||
| InitializeEtwMonitor( | ||
| sourceETW, | ||
| etwProviders); | ||
| break; | ||
| } | ||
| default: | ||
| logWriter.TraceWarning( | ||
| L"Log source type not supported for monitoring"); | ||
| break; | ||
| } |
Check notice
Code scanning / CodeQL
No trivial switch statements
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, the switch statement should be replaced with an if/else structure. This involves:
- Replacing the
switchstatement with anifcondition for theLogSourceType::ETWcase. - Adding an
elseblock to handle the default case. - Ensuring the functionality remains unchanged.
The changes will be made in the StartMonitors function, specifically in the block starting at line 60.
Suggested changeset
1
LogMonitor/src/LogMonitor/LogMonitorAPI.cpp
| @@ -59,18 +59,15 @@ | ||
| { | ||
| switch (source->Type) | ||
| { | ||
| case LogSourceType::ETW: | ||
| { | ||
| std::shared_ptr<SourceETW> sourceETW = | ||
| std::reinterpret_pointer_cast<SourceETW>(source); | ||
| InitializeEtwMonitor( | ||
| sourceETW, | ||
| etwProviders); | ||
| break; | ||
| } | ||
| default: | ||
| logWriter.TraceWarning( | ||
| L"Log source type not supported for monitoring"); | ||
| break; | ||
| } | ||
| if (source->Type == LogSourceType::ETW) | ||
| { | ||
| std::shared_ptr<SourceETW> sourceETW = | ||
| std::reinterpret_pointer_cast<SourceETW>(source); | ||
| InitializeEtwMonitor( | ||
| sourceETW, | ||
| etwProviders); | ||
| } | ||
| else | ||
| { | ||
| logWriter.TraceWarning( | ||
| L"Log source type not supported for monitoring"); | ||
| } | ||
| } |
Copilot is powered by AI and may make mistakes. Always verify output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.