clean cppcheck warnings in the iis/ ext/ and mlogc/ directories#3596
Open
umprayz wants to merge 3 commits into
Open
clean cppcheck warnings in the iis/ ext/ and mlogc/ directories#3596umprayz wants to merge 3 commits into
umprayz wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request aims to make the codebase cppcheck-clean in the iis/, ext/, and mlogc/ directories (and updates the cppcheck Makefile target to scan them), primarily through const-correctness, null-safety, and warning suppressions. It also adjusts the standalone API write-callback signatures used by the IIS module.
Changes:
- Expand
make cppcheckto scanmlogc/,iis/, andext/in addition tostandalone/. - Apply const-correctness and nullptr cleanups across IIS and extension code; adjust standalone write-callback signatures accordingly.
- Address (some) warning-driven issues in
mlogc(e.g., allocation checks, local variable scoping, const qualifiers).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
Makefile.am |
Extends the cppcheck target to include mlogc/, iis/, and ext/. |
standalone/api.h |
Changes write-callback setter prototypes to accept const char *buf. |
standalone/api.c |
Changes write-callback setter definitions to accept const char *buf. |
mlogc/mlogc.c |
Adjusts constness and local variable scoping; adds some warning suppressions and allocation-guarding. |
iis/mymodule.cpp |
Replaces NULL with nullptr, tightens const usage, and updates write callbacks to const char *. |
iis/moduleconfig.h |
Moves m_Config and adds a cppcheck suppression comment. |
iis/moduleconfig.cpp |
Reworks exception handling assignments; includes comment updates and keeps constructor member init list. |
iis/main.cpp |
Adds cppcheck suppression for a redundant assignment and adjusts comment placement. |
ext/mod_var_remote_addr_port.c |
Makes variable parameters const where applicable. |
ext/mod_op_strstr.c |
Adds const qualifiers and local initialization changes in Boyer–Moore–Horspool code and operator exec signature. |
Comments suppressed due to low confidence (1)
mlogc/mlogc.c:707
startis still NULL when used in the pointer comparisonp > start, which is undefined/meaningless and can break the newline-trimming logic. Compare againstline(the start of the buffer) instead.
/* Remove the trailing newline character. */
p = (char *)line;
while(*p != '\0') p++;
if ((p > start)&&(*(p - 1) == '\n')) *(p - 1) = '\0';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
399
to
+404
| entry = (entry_t *)malloc(sizeof(entry_t)); | ||
| entry->id = 0; | ||
| entry->line = strdup(data); | ||
| entry->line_size = strlen(entry->line); | ||
| if(entry != NULL){ | ||
| entry->id = 0; | ||
| entry->line = strdup(data); | ||
| entry->line_size = strlen(entry->line); | ||
| } |
Comment on lines
474
to
+477
| MODSECURITY_STORED_CONTEXT::MODSECURITY_STORED_CONTEXT(): | ||
| m_bIsEnabled ( FALSE ), | ||
| m_pszPath( NULL ), | ||
| m_Config( NULL ) | ||
| m_Config( NULL ) |
Comment on lines
+687
to
692
| void modsecSetWriteBody(apr_status_t (*func)(request_rec *r, const char *buf, unsigned int length)) { | ||
| modsecWriteBody = func; | ||
| } | ||
|
|
||
| void modsecSetWriteResponse(apr_status_t (*func)(request_rec *r, char *buf, unsigned int length)) { | ||
| void modsecSetWriteResponse(apr_status_t (*func)(request_rec *r, const char *buf, unsigned int length)) { | ||
| modsecWriteResponse = func; |
Comment on lines
+1110
to
+1112
| if (readcnt != nullptr) { | ||
| *readcnt = static_cast<unsigned int>(dwReadcnt); | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
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.



what
iis/ext/andmlogc/directories.why
api.candapi.hfiles in thestandalone/directory, in order to resolve a warning in these two function:modsecSetWriteBody()andmodsecSetWriteResponse(). Themymodule.cppuses them in itsWriteResponseCallback()andWriteBodyCallback()functions.references
<fix: cppcheck warnings in standalone/ fix: cppcheck warnings in standalone/ #3488>