Skip to content

Unify main() error-path cleanup #209

Merged
jserv merged 1 commit into
sysprog21:mainfrom
henrybear327:refactor/single_exit_point
Jul 16, 2026
Merged

Unify main() error-path cleanup #209
jserv merged 1 commit into
sysprog21:mainfrom
henrybear327:refactor/single_exit_point

Conversation

@henrybear327

@henrybear327 henrybear327 commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary by cubic

Centralized main() cleanup with a goto-based unwind to ensure consistent resource release on all exits and fix a temporary ELF file leak. This reduces duplicated error-path code and makes failure handling more reliable.

  • Bug Fixes

    • Always unlink the temporary host ELF (elf_host_path) on any exit, covering post-prepare failures and Rosetta teardown.
    • Route the success path through cleanup to ensure sysroot unmount, cwd restore, and argv/path frees always run.
  • Refactors

    • Replaced repeated cleanup-and-return blocks with fail/cleanup labels and a single exit_code.
    • Removed duplicated per-branch cleanup and unlink calls, simplifying control flow.

Written for commit ae65cf1. Summary will update on new commits.

Review in cubic

@henrybear327 henrybear327 changed the title Unify main() error-path cleanup with a goto unwind Unify main() error-path cleanup Jul 16, 2026
@henrybear327
henrybear327 requested a review from jserv July 16, 2026 07:51
Comment thread src/main.c Outdated
@henrybear327
henrybear327 force-pushed the refactor/single_exit_point branch from db14471 to ae65cf1 Compare July 16, 2026 12:58
@henrybear327
henrybear327 requested a review from jserv July 16, 2026 12:59
@jserv
jserv merged commit a27c26c into sysprog21:main Jul 16, 2026
9 checks passed
@jserv

jserv commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Thank @henrybear327 for contributing!

@henrybear327
henrybear327 deleted the refactor/single_exit_point branch July 16, 2026 15:46
henrybear327 pushed a commit to henrybear327/elfuse that referenced this pull request Jul 17, 2026
…it_point

Unify main() error-path cleanup
henrybear327 pushed a commit to henrybear327/elfuse that referenced this pull request Jul 17, 2026
…it_point

Unify main() error-path cleanup
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