Skip to content

refactor(ninit): extract core prelude into ninit_core.c - #52

Merged
Iky969 merged 1 commit into
mainfrom
refactor/ninit-core-extraction
Dec 1, 2026
Merged

Iky969 merged 1 commit into
mainfrom
refactor/ninit-core-extraction

Conversation

@Iky969

@Iky969 Iky969 commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Move the configuration macros, service state/type definitions, shared globals, and forward declarations into ninit_core.c.
  • Include the new module at the original prelude location, preserving the unity build and one static /sbin/init binary.
  • Remove one pre-existing trailing space in the moved deps_str declaration so git diff --check remains clean; no production logic changes.

Verification

  • Confirmed all 107 moved prelude lines match HEAD:ninit.c; the only difference is the removed trailing space.
  • sh scripts/check-ninit-c-refs.sh — pass.
  • make clean && make && make ninit-test && make ubsan — pass.
  • make lint — pass.
  • make fuzz — 38/38 checks pass, zero ASan/UBSan reports.
  • python3 scripts/test-ci-workflow.py — 9 passed, 0 failed.
  • sudo make test — full 13-suite matrix passed on the final run.
  • readelf -lW ninit / readelf -dW ninit — no INTERP/DYNAMIC segment and no dynamic section.
  • The resulting ninit binary is byte-identical to a clean build of base commit 40222e2; both SHA-256 hashes are b4b528658c2f2480ed633c3cf1b118efa51b2eb6a88f7fe1d20e68914e1f5f00.

Local test note

  • The first full-suite run hit one transient Scenario 9 descendant-cleanup assertion. The isolated test-cgroup-limits.sh rerun and the subsequent full sudo make test run both passed without any source change. The byte-identical baseline comparison confirms that the extraction did not change the produced binary.

Summary by CodeRabbit

  • Refactor
    • Consolidated shared service configuration and lifecycle details. No user-facing behavior changes are noted.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Shared core declarations

Layer / File(s) Summary
Centralize core declarations
ninit_core.c, ninit.c
ninit_core.c defines configuration defaults, service lifecycle types, shared state, and forward declarations. ninit.c replaces its inline prelude with an include of ninit_core.c.

Suggested reviewers: fyxm969

Change: Refactor

Merge Risk: Minimal · up to c6443

This refactor moves shared declarations into a separate file that is still compiled as part of the same binary, so runtime behavior should not change. No specific merge-blocking risk was identified.

Security architecture risk: Minimal · up to c6443

The PR moves existing declarations into an included file. It does not change how ninit starts, manages services, or exposes its controls.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 53dc3240-f845-4af5-a6d0-27e2bef9df2d
Commits

Reviewing files that changed from the base of the PR and between 40222e2 and c6443ee.

Files selected for processing: 2

  • ninit.c
  • ninit_core.c

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@kilo-code-bot

kilo-code-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Code Review Roast 🔥

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

A 107-line code-motion refactor where the moved block is byte-for-byte identical to the original (minus one lonely trailing space that nobody will miss), the include lands after the system headers, the Makefile only treats ninit_*.c as rebuild dependencies so there's no duplicate-symbol fireworks, and the new file copies the existing ninit_logging.c unity pattern down to the header comment. It's so boring I could weep with joy.

📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are.

Files Reviewed (2 files)
  • ninit.c
  • ninit_core.c

Reviewed by free · Input: 29.4K · Output: 3.6K · Cached: 278K

@Iky969
Iky969 merged commit 410edcd into main Dec 1, 2026
14 checks passed
@Iky969
Iky969 deleted the refactor/ninit-core-extraction branch December 1, 2026 04:20
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