Skip to content

src: clear the two intentional empty-body CodeQL warnings - #59

Merged
schivei merged 1 commit into
mainfrom
clear-intentional-empty-bodies
Oct 7, 2026
Merged

schivei merged 1 commit into
mainfrom
clear-intentional-empty-bodies

Conversation

@schivei

@schivei schivei commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

With the code-scanning merge bar raised to block at any alert level, the two remaining empty-control-body warnings in src/*.mc (intentional idioms, flagged by minicompiler/codeql-mc) would block every merge. Both are rewritten to the same behaviour with no empty body:

  • ns.mc if (ph_accept("\\", 1)) {} → ph_accept("\\", 1); — the return was already discarded; this is the consume-if-present idiom class.mc:326,339 already use.
  • rc.mc the empty first branch of the if/else-if dispatch, inverted by De Morgan: if (!(… php_str_repeat …)) { if (php_str_setb …) {…} else bad }. Equivalent — a php_str_repeat assignment into the name still takes no fallback walk, any other call is walked or is a leak.

Behaviour-preserving: mc build + tests/fixtures.sh green. After this, the mc CodeQL scan over src/*.mc is clean (the 3 real findings were removed in #57; these were the 2 intentional ones).

🤖 Generated with Claude Code

With the code-scanning bar now blocking a merge at any alert level, the two
intentional empty-control-body warnings had to go. Both rewritten to the same
behaviour without an empty body:
- ns.mc: 'if (ph_accept("\\", 1)) {}' -> 'ph_accept("\\", 1);' -- the
  return was already discarded; this is the idiom class.mc:326,339 already use.
- rc.mc: the empty first branch of the if/else-if dispatch inverted by De
  Morgan -- 'if (!(... php_str_repeat ...)) { if (php_str_setb) {...} else bad }'
  -- equivalent: a php_str_repeat assignment still takes no fallback walk.

Behaviour-preserving (fixtures.sh green). minicompiler/codeql-mc's src/*.mc scan
is now clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Both rewrites are behaviorally equivalent and consistent with existing code patterns.

Review effort: Balanced
Findings: None

What changed in this PR

Removes two intentional empty-body patterns while preserving behavior and clearing CodeQL warnings.

Changes:

  • Simplifies optional namespace separator consumption.
  • Rewrites fresh-buffer dispatch without an empty branch.
File Description
src/​ns.mc Discards ph_accept’s result directly.
src/​rc.mc Inverts the dispatch while preserving fallback analysis.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@schivei
schivei merged commit b8d568a into main Oct 7, 2026
13 checks passed
@schivei
schivei deleted the clear-intentional-empty-bodies branch October 7, 2026 12:12
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.

2 participants