Skip to content

Fix version-check macro precedence and collapse write_begin variants - #96

Merged
jserv merged 2 commits into
sysprog21:masterfrom
RoyWFHuang:bug/kernel_ver_macro
Aug 9, 2026
Merged

Fix version-check macro precedence and collapse write_begin variants#96
jserv merged 2 commits into
sysprog21:masterfrom
RoyWFHuang:bug/kernel_ver_macro

Conversation

@RoyWFHuang

@RoyWFHuang RoyWFHuang commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

1. Add missing parentheses to version-check macros

SIMPLEFS_AT_LEAST() and SIMPLEFS_LESS_EQUAL() lacked outer parentheses:

#define SIMPLEFS_AT_LEAST(major, minor, rev)  LINUX_VERSION_CODE >= KERNEL_VERSION(major, minor, rev)

Unary ! binds tighter than >=, so #if !SIMPLEFS_AT_LEAST(6, 15, 0) in file.c expanded to #if (!LINUX_VERSION_CODE) >= KERNEL_VERSION(6, 15, 0), which is false on every kernel. .writepage was dropped from simplefs_aops everywhere, not just on 6.15+.

2. Collapse duplicated simplefs_write_begin variants

The four per-kernel variants each carried a full copy of the same body, differing only in signature and in the arguments to block_write_begin().


Summary by cubic

Fixes version-check macro precedence and deduplicates simplefs_write_begin. Restores correct kernel gating (e.g., .writepage only dropped on 6.15+) and reduces maintenance.

  • Bug Fixes

    • Parenthesized SIMPLEFS_AT_LEAST() and SIMPLEFS_LESS_EQUAL() to enforce correct precedence.
    • Fixed #if !SIMPLEFS_AT_LEAST(6, 15, 0) mis-evaluation that dropped .writepage on all kernels.
  • Refactors

    • Collapsed four kernel-specific simplefs_write_begin variants into one implementation.
    • Kept a single body; only the block_write_begin() call/signature is selected via version guards.

Written for commit 65bec5b. Summary will update on new commits.

Review in cubic

The SIMPLEFS_AT_LEAST/SIMPLEFS_LESS_EQUAL macro bodies lacked outer
parentheses.
The four per-kernel simplefs_write_begin variants duplicated the same
body and differed only in signature and the block_write_begin call.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 2 files

Re-trigger cubic

@RoyWFHuang
RoyWFHuang requested a review from jserv August 9, 2026 05:56
@jserv
jserv merged commit db7f94c into sysprog21:master Aug 9, 2026
4 checks passed
@jserv

jserv commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Thank @RoyWFHuang for contributing!

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