Skip to content

Reduce Warnings#95

Open
Lightning11wins wants to merge 12 commits into
masterfrom
reduce-warnings
Open

Reduce Warnings#95
Lightning11wins wants to merge 12 commits into
masterfrom
reduce-warnings

Conversation

@Lightning11wins

Copy link
Copy Markdown
Contributor

This PR greatly reduces / nearly eliminates warnings when building centrallix, centrallix-lib, and their associated test suites with default configuration flags. This will reduce the number of bugs that make it to production in the future by making legitimate warnings far more obvious when building the project.

Ignore uninitialized warnings in mtask that are intended behavior.
Fix discards const warning in qpf_internal_hexdecode().
Clean up.
…for functions that expected chars with no cast.

Clean up.
Remove unused n variable from test_mtlexer_07.c.
Remove unused commonnames variable from test_mtlexer_15.c and test_mtlexer_16.c.
Remove iter variable from test_02baseline.c that's initialized but never used.
Add initialization code for the array variable in test_00baseline.c and test_03baseline.c.

Clean up.
Fix aposSetLimits() recording the return value of aposSetLimits_r(), but then always returning 0.
Remove rval variable from nht_i_GET() because it was never read.
Comment out code that isn't used anymore due to nearby code being commented out.
Clean up.
Add typecasts to function pointers to explicitly change the type.
Add typecasts to hexify tests.
@Lightning11wins Lightning11wins self-assigned this Apr 7, 2026
@Lightning11wins Lightning11wins added enhancement ai-review Request AI review for PRs. labels Apr 7, 2026
@Lightning11wins

Copy link
Copy Markdown
Contributor Author

@greptileai Please review this code anyway.

@greptile-apps

greptile-apps Bot commented Apr 7, 2026

Copy link
Copy Markdown

Greptile Summary

This PR removes or suppresses compiler warnings across 114 files in centrallix and centrallix-lib, with changes ranging from removing genuinely dead variables and unused global structs to adding #pragma GCC diagnostic guards and (char*) casts. One incidental real fix is included: aposSetLimits now propagates the error return from aposSetLimits_r instead of always returning 0.

  • Dead code removal (htmlgen, multiquery, netdrivers, osdrivers): Unused idcnt global structs and their derived id locals are deleted from a dozen htdrv_*.c files; unused variables (rval, objlist, is_outer, box_offset, bx/by/bw/bh) are removed from several core files — all safe, no behaviour change.
  • Warning suppression via pragmas (mtask.c): #pragma GCC diagnostic push/pop wraps the intentionally uninitialized stack reads that MTASK requires; this is the appropriate mechanism for deliberately unsafe-looking but required code.
  • Const-casting in cxss_credentials_mgr.c: const char* parameters passed to cxssShred are cast to char* to silence the discarded-qualifier warning, silencing a signal that the function signatures should not promise const for buffers they will shred.

Confidence Score: 5/5

Safe to merge — the changes are overwhelmingly dead-code removal with no behaviour change, plus one genuine bug fix in aposSetLimits.

The vast majority of changes remove variables that were assigned but never read, or delete unused global counters. The pragma-based suppression in mtask.c is the right tool for intentionally unsafe stack code. The const-casting in cxss_credentials_mgr.c obscures an API design smell but does not introduce new misbehaviour. The aposSetLimits return-value fix is a correct improvement.

centrallix/cxss/cxss_credentials_mgr.c (const-casting) and centrallix/utility/json_util.c (empty else-if branches) are worth a second look for long-term cleanliness, but neither poses a runtime risk.

Important Files Changed

Filename Overview
centrallix-lib/src/mtask.c Added #pragma GCC diagnostic push/pop to suppress intentional uninitialized stack reads used for MTASK's stack-allocation trick across three functions.
centrallix/wgtr/apos.c Removed unused variables; also fixes aposSetLimits to return the actual rval from aposSetLimits_r rather than always returning 0.
centrallix/utility/json_util.c Commented-out has_hour/minute/second/tz tracking variables replaced with empty else if (cond); no-op branches; functionally identical but leaves confusing dead code.
centrallix/cxss/cxss_credentials_mgr.c Added (char*) casts throughout to suppress discarded-const warnings when passing caller-provided keys to cxssShred; masks an API const-correctness issue.
centrallix/multiquery/multiq_equijoin.c Removed is_outer variable which was assigned but never read anywhere in the function.
centrallix/htmlgen/htdrv_window.c Commented out bx/by/bw/bh geometry block — those variables were computed but never consumed; no functional change.
centrallix/netdrivers/net_http.c Dropped unused rval variable that stored nht_i_RestGet's return value without ever being checked.
centrallix/htmlgen/htdrv_connector.c Removed idcnt-based global struct and the id local variable derived from it, which were computed but unused.
centrallix/cxss/cxss_crypto.c Changed seed buffer from char[256] to unsigned char[256] to match the expected type of cxss_internal_GetBytes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Warning Sources] --> B[Unused variables]
    A --> C[Intentional uninitialized stack reads]
    A --> D[Signed vs unsigned mismatch]
    A --> E[Discarded const qualifier]

    B --> B1[Delete variable and assignment]
    C --> C1[pragma GCC diagnostic push/pop]
    D --> D1[char to unsigned char]
    E --> E1[Cast away const with char-ptr]

    B1 --> F[No behaviour change]
    C1 --> F
    D1 --> F
    E1 --> G[Warning silenced but const API issue remains]

    style G fill:#ffcccc
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Warning Sources] --> B[Unused variables]
    A --> C[Intentional uninitialized stack reads]
    A --> D[Signed vs unsigned mismatch]
    A --> E[Discarded const qualifier]

    B --> B1[Delete variable and assignment]
    C --> C1[pragma GCC diagnostic push/pop]
    D --> D1[char to unsigned char]
    E --> E1[Cast away const with char-ptr]

    B1 --> F[No behaviour change]
    C1 --> F
    D1 --> F
    E1 --> G[Warning silenced but const API issue remains]

    style G fill:#ffcccc
Loading

Reviews (2): Last reviewed commit: "Add explicit casts to remove const in we..." | Re-trigger Greptile

@Lightning11wins

Copy link
Copy Markdown
Contributor Author

Wow, sounds great.

This PR is cleared for human review.

@Lightning11wins Lightning11wins added size: medium Might be hard to review, usually less than ~5000 lines. and removed enhancement labels Apr 27, 2026
@Lightning11wins

Copy link
Copy Markdown
Contributor Author

The conversation is getting a little cluttered, so I think I should repost this.

This PR is cleared for human review.

@Lightning11wins

Copy link
Copy Markdown
Contributor Author

With those commits, I think I've successfully eliminated all warnings on the latest current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request AI review for PRs. size: medium Might be hard to review, usually less than ~5000 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant