Skip to content

Log qprintf Errors in xstring.c - #103

Open
Lightning11wins wants to merge 27 commits into
masterfrom
log-qprintf-errors-xstring
Open

Log qprintf Errors in xstring.c#103
Lightning11wins wants to merge 27 commits into
masterfrom
log-qprintf-errors-xstring

Conversation

@Lightning11wins

@Lightning11wins Lightning11wins commented May 14, 2026

Copy link
Copy Markdown
Contributor

Quick change that improves error handling of qprintf errors in xstring.c.

GitHub Relationships

These will need to be reviewed and merged into master before this PR is reviewed.

…branch).

Fix a bug in qprintf() that caused % and & characters inside conditional printing areas to always print, regardless of the condition.
Improve documentation for qpfPrintf_va_internal() and qpf_grow_fn_t().
Clean up.
Reorder some code to improve clarity.
Add various comments.
Fix spacing mistakes.
Add void to function signatures that do not take parameters.
Clean up some overly cleaver code.
…d more comments.

Overhaul qpf_internal_Translate() to improve readability.
Improve readability of qpf_internal_SetupTable().
Improve code in multiple functions that ensures the module is initialized.
Clean up and improve function doc comments.
Add line numbers to errors.
Add qpfLogErrors().
Add qpf_internal_getErrorName().
Add qpf_internal_count_zeros().
Add QPF_ERR_T_NO_ERRORS.
Add QPF_ERR_COUNT.
Improve formating of QPF_ERR_T defines.
Add docs for session functions.
Add license.
Clarify how to use source and filter format specifiers.
Simplify wording for filter specifiers to improve readability.
Fix is_only_followed_by_nlen using || instead of &&.
Fix closing quote space check didn't handle buffer overflows very well.
Fix null_session error line numbers not being initialized.
Fix qpfClearErrors() being lazy about clearing error line numbers.
Fix qpf_internal_count_zeros(0) edge case.
Fix a quote buffer overflow comment from Greptile.
Add test_qprintf_69.c to validate that the "fixed" code now works properly.

Note: Honestly, I'm so in the weeds that I only understand about 80% of what's going on here, but it works, and this probably isn't worth a ton of additional effort.
Remove an error check that always passed.
Add more explicit typecasts.
Update qpf_internal_itoa() to return size_t because it cannot error.
Add an UNLIKELY() to speed up qpf_internal_itoa().
Fix missing info in the qpf_internal_itoa() doc comment.
Add a test case to verify that the buffer underflow is fixed.
Clean up and improve correctness of test cases added on this branch.
…unsigned ints.

Add an error message if a line number overflows USHRT_MAX.
Add a doc comment to error sessions.
Update copyright notice dates and descriptions.
Clean up and improve some spacing.
Add doc comment to QPSession.
Add qpfNoGrow() and qpfSysMallocGrow() grow functions for use when calling qpfPrint_g*() functions.
Add qpfPrintf_g() and qpfPrintf_gva() qprintf variants that allow passing a grow function.
Improve doc comments for all qpfPrintf*() functions.
Add code to use a pQPSession to record errors.
Add call to qpfLogErrors() when an error occurs.
Update copyright notice.
Clean up.
@Lightning11wins Lightning11wins self-assigned this May 14, 2026
@Lightning11wins Lightning11wins added ai-review Request AI review for PRs. size: trivial Easy to review, probably ~100 lines or fewer. labels May 14, 2026
@greptile-apps

greptile-apps Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR expands qprintf error-session diagnostics and uses them to report failures from XString formatting, while also refactoring the qprintf implementation and adding buffer-boundary regression coverage.

  • Records source lines for qprintf error categories and exposes error logging.
  • Updates xs_internal_QPrintf to create, log, and close an error session safely.
  • Adds tests covering one- and two-byte quoted-output buffers.
  • Updates the qprintf API declarations and documentation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
centrallix-lib/include/qprintf.h Extends the public session structure and API declarations for recording and logging qprintf errors.
centrallix-lib/src/qprintf.c Adds per-error source-line tracking and logging while substantially refactoring formatting and buffer-management code.
centrallix-lib/src/xstring.c Integrates qprintf error sessions into XString formatting and safely handles session-allocation failure.
centrallix-lib/tests/test_qprintf_69.c Adds regression coverage for quoted output in a two-byte destination buffer.
centrallix-lib/tests/test_qprintf_70.c Adds regression coverage preventing underflow around a one-byte destination buffer.
centrallix-sysdoc/QPrintf.md Documents error-session APIs and clarifies the supported qprintf format specifiers.

Reviews (3): Last reviewed commit: "Merge branch 'master' into log-qprintf-e..." | Re-trigger Greptile

Comment thread centrallix-lib/src/xstring.c Outdated
@Lightning11wins

Copy link
Copy Markdown
Contributor Author

This PR is ready for human review.

@Lightning11wins
Lightning11wins requested review from gbeeley and nboard May 14, 2026 20:45
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