Skip to content

Add Error Messages & Improve Error Handling#88

Open
Lightning11wins wants to merge 4 commits into
masterfrom
improve-error-handling
Open

Add Error Messages & Improve Error Handling#88
Lightning11wins wants to merge 4 commits into
masterfrom
improve-error-handling

Conversation

@Lightning11wins
Copy link
Copy Markdown
Contributor

Changes extracted from #85.
Should not affect business logic, other than improving error case handling. Review should be easy.

@Lightning11wins Lightning11wins self-assigned this Mar 4, 2026
@Lightning11wins Lightning11wins added enhancement ai-review Request AI review for PRs. labels Mar 4, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Mar 4, 2026

Greptile Summary

This PR adds fprintf(stderr, ...) warning messages to the error paths of cxsecVerifySymbol and cxsecVerifySymbol_n, converting bare return -1 statements into goto err jumps that print the offending symbol before returning. Both functions correctly save the original pointer (and length for the _n variant) before any mutation, addressing the stale-pointer issue flagged in earlier review threads.

Confidence Score: 5/5

Safe to merge after renaming err: to error: per project convention.

Only P2 (style) findings remain; the previously-flagged logic bugs (stale pointer, format specifiers, non-null-terminated %s) are all correctly addressed in this revision.

centrallix-lib/src/cxsec.c — minor label-naming convention mismatch.

Important Files Changed

Filename Overview
centrallix-lib/src/cxsec.c Adds warning output on invalid-symbol paths in cxsecVerifySymbol and cxsecVerifySymbol_n; correctly saves original pointer/length before mutation, but uses err: label instead of the project-mandated error: label.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["cxsecVerifySymbol(sym)"] --> B["save original_symbol = sym"]
    B --> C{"First char valid?\n[A-Za-z_]"}
    C -- No --> E["goto err\nfprintf(stderr, WARNING '%s'...)"]
    C -- Yes --> D["walk remaining chars"]
    D --> F{"All chars valid?\n[A-Za-z0-9_]"}
    F -- No --> E
    F -- Yes --> G["return 0"]
    E --> H["return -1"]

    A2["cxsecVerifySymbol_n(sym, n)"] --> B2["save original_symbol, original_n"]
    B2 --> C2{"n==0 or first char invalid?"}
    C2 -- Yes --> E2["goto err\nfprintf(stderr, WARNING '%.*s'...)"]
    C2 -- No --> D2["walk n-1 remaining chars"]
    D2 --> F2{"All chars valid?"}
    F2 -- No --> E2
    F2 -- Yes --> G2["return 0"]
    E2 --> H2["return -1"]
Loading

Reviews (4): Last reviewed commit: "Apply changes to cxsecVerifySymbol()." | Re-trigger Greptile

Comment thread centrallix-lib/src/cxsec.c
Comment thread centrallix-lib/src/cxsec.c Outdated
@Lightning11wins
Copy link
Copy Markdown
Contributor Author

@greptileai Please re-review this PR and let me know if you have any other comments, or let me know if the PR is ready to merge.

Comment thread centrallix-lib/src/cxsec.c Outdated
@Lightning11wins
Copy link
Copy Markdown
Contributor Author

@greptileai I fixed your previous issues and also made more changes. Double check that the previous issues are fixed and scan the new changes to ensure that they don't have any issues.

@Lightning11wins
Copy link
Copy Markdown
Contributor Author

Lightning11wins commented Mar 12, 2026

PR cleared for human review.

@Lightning11wins Lightning11wins added size: trivial Easy to review, probably ~100 lines or fewer. and removed enhancement labels Apr 27, 2026
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: trivial Easy to review, probably ~100 lines or fewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant