Skip to content

Conversation

EricccTaiwan
Copy link
Collaborator

@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 <[email protected]>
@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
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.

Improve readability of devicemodel_remove() version-dependent definition

2 participants