Skip to content

fix: improve const-correctness in Expat.xs#254

Draft
toddr-bot wants to merge 1 commit intomainfrom
koan.toddr.bot/const-correctness
Draft

fix: improve const-correctness in Expat.xs#254
toddr-bot wants to merge 1 commit intomainfrom
koan.toddr.bot/const-correctness

Conversation

@toddr-bot
Copy link
Copy Markdown
Collaborator

@toddr-bot toddr-bot commented Apr 10, 2026

What

Fix const-correctness in Expat.xs by propagating const char * through internal helper functions.

Why

Expat callbacks receive const XML_Char * parameters, but newUTF8SVpv(), newUTF8SVpvn(), and append_error() took plain char *. This forced 30+ explicit (char *) casts throughout the file, silently discarding const qualifiers. Compilers couldn't catch accidental mutation of expat-owned strings.

How

  • Changed newUTF8SVpv(), newUTF8SVpvn(), and append_error() to accept const char *
  • Removed all 30+ now-unnecessary (char *) casts at call sites
  • Replaced (char *) 0 with NULL (3 occurrences)
  • Removed a redundant cast on the enc variable in XML_ParserCreate
  • Left the one legitimate (char *) cast in the encoding loader (byte-level pointer arithmetic)

No functional change — the generated machine code is identical.

Testing

Full make test passes (59 programs, 677 subtests). Clean build with zero warnings.

🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 42 insertions(+), 42 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 95.23810% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.40%. Comparing base (4ee8e6f) to head (a621953).

Files with missing lines Patch % Lines
Expat/Expat.xs 95.23% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #254   +/-   ##
=======================================
  Coverage   76.40%   76.40%           
=======================================
  Files           1        1           
  Lines        1102     1102           
  Branches      346      346           
=======================================
  Hits          842      842           
  Misses         52       52           
  Partials      208      208           
Flag Coverage Δ
perl 76.40% <95.23%> (ø)
xs 76.40% <95.23%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Change newUTF8SVpv(), newUTF8SVpvn(), and append_error() to accept
const char* parameters, matching the const XML_Char* types from
expat callbacks. This removes 30+ unnecessary (char*) casts that
were discarding const qualifiers throughout the file.

Also replace three (char*) 0 null pointer idioms with NULL and
remove a redundant cast on the enc variable in XML_ParserCreate.

No functional change — purely a type-correctness cleanup that
lets the compiler enforce const safety.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@toddr-bot
Copy link
Copy Markdown
Collaborator Author

Rebase with requested adjustments

Branch koan.toddr.bot/const-correctness was rebased onto main and review feedback was applied.

Stats

1 file changed, 42 insertions(+), 42 deletions(-)
Actions performed
  • Already-solved check: negative (confidence=high, reasoning=None of the recent commits on main address const-correctness in Expat.xs — the commits cover unrelat)
  • Resolved merge conflicts (1 round(s))
  • Rebased koan.toddr.bot/const-correctness onto origin/main
  • Pre-push CI check: previous run passed
  • Force-pushed koan.toddr.bot/const-correctness to origin
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Kōan

@toddr-bot toddr-bot force-pushed the koan.toddr.bot/const-correctness branch from 4d99126 to a621953 Compare April 23, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant