Skip to content

examples: Refactor device model with version-based split #321

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 18, 2025

Conversation

EricccTaiwan
Copy link
Contributor

@EricccTaiwan EricccTaiwan commented May 18, 2025

The previous implementation of devicemodel_remove used conditional compilation to switch between void and int return types based on the kernel version. While functionally correct, the interleaved #if/#endif blocks made the logic harder to follow.

This refactor cleanly separates the two function definitions using a full #if/#else block around the entire function.

No functional behavior is changed.

Close: #313

Summary by Bito

This pull request refactors the device model implementation, enhancing the readability of the devicemodel_remove function. It replaces conditional compilation with a clearer structure that separates function definitions by kernel version, without changing the functional behavior of the code.

Unit tests added: False

Estimated effort to review (1-5, lower is better): 2

The previous implementation of devicemodel_remove used conditional
compilation to switch between void and int return types based on
the kernel version. While functionally correct, the interleaved
`#if/#endif` blocks made the logic harder to follow.

This refactor cleanly separates the two function definitions using
a full `#if/#else` block around the entire function.

No functional behavior is changed.

Close: sysprog21#313

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
@jserv jserv merged commit 8016001 into sysprog21:master May 18, 2025
1 check passed
@jserv
Copy link
Contributor

jserv commented May 18, 2025

Thank @EricccTaiwan for contributing!

@EricccTaiwan EricccTaiwan deleted the example-refactor branch May 18, 2025 14:47
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve readability of devicemodel_remove() version-dependent definition
2 participants