chore(warnings): mechanical low-risk cleanup pass #499#513
Merged
TheWitness merged 1 commit intoCacti:developfrom Mar 25, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR primarily tightens C API contracts across the codebase (const-correctness and proper (void) prototypes), fixes a handful of small correctness issues, and adds an initial unit test for string utilities.
Changes:
- Update multiple function prototypes to use
const char *where appropriate and(...)(void)for no-arg functions. - Fix/cleanup logic in several areas (e.g.,
db_column_exists()query routing,strncopy()usage inping.c, removal of unused variables, unused-parameter suppressions). - Add a cmocka unit test covering
strpos()behavior.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| util.h | Updates prototypes (const-correctness, (void) args) and exports poller_push_data_to_main(). |
| util.c | Aligns implementations with updated signatures; refactors return types for DB-backed getters; const cleanup in string helpers; adds poller_push_data_to_main(void) signature. |
| tests/unit/test_util_strings.c | Adds unit tests for strpos() using cmocka with local stubs/mocks. |
| sql.h | Makes db_reconnect() location parameter const char *; minor cleanup. |
| sql.c | Updates db_reconnect() signature and fixes db_column_exists() to use the passed connection type. |
| spine.c | Updates forward declaration and renames debug-device parsing index for clarity. |
| snmp.h | Makes SNMP OID parameters const char * in public APIs. |
| snmp.c | Aligns SNMP functions with updated const signatures; suppresses unused-parameter warnings in snmp_snprint_value(). |
| poller.h | Makes exec_poll() type parameter const char *. |
| poller.c | Suppresses unused parameters in cleanup handlers; removes unused snmp_poller_items; aligns exec_poll() signature; removes unnecessary cast for nft_popen(). |
| ping.c | Renames local timing vars for clarity; makes cacti_msg const; fixes strncopy() length argument. |
| php.c | Reworks argv constant strings for script-server spawn to avoid transient formatted buffers. |
| nft_popen.c | Avoids const-cast by duplicating the command string; frees duplication in parent paths. |
| locks.c | Uses (void) prototype for init_mutexes; makes internal get_name() static. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Contributor
Author
This was referenced Mar 24, 2026
Mechanical cleanup of compiler warnings plus targeted bug fixes: - Add void to empty parameter lists (init_mutexes, poller_push_data_to_main) - Mark file-local functions static (get_name in locks.c) - Add const to read-only string parameters (snmp_oid, nft_popen command) - Add UNUSED_PARAMETER for callback args - Fix strncopy length in get_namebyhost (was no-op after memset) - Fix db_column_exists to use passed type instead of hardcoded LOCAL - Fix getglobalvariable to strdup opttable value (fixes latent use-after-free) - Change getsetting/getpsetting/getglobalvariable return to char* (ownership) - Remove write-only snmp_poller_items counter - Add strpos unit tests Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1e8cc9f to
2834e19
Compare
TheWitness
approved these changes
Mar 25, 2026
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.
Fixes compiler warnings across spine source files: adds missing void in function prototypes, marks internal functions static, removes unused variables, and fixes const-correctness on function signatures.
Note: This PR also includes the following non-mechanical changes that should be reviewed carefully:
Addressed performance and DRY issues:
Test plan