Skip to content

Conversation

visitorckw
Copy link
Contributor

Simplify the init routine by:

  • Removing unnecessary temporary variables
  • Adding spacing between declarations and statements
  • Using early return on alloc_chrdev_region() failure
  • Propagating the actual error code instead of always returning -1
  • Dropping redundant checks in the error path

This makes the error handling clearer and more consistent with common kernel coding style.

@EricccTaiwan EricccTaiwan requested a review from jserv September 3, 2025 08:27
examples/ioctl.c Outdated
Comment on lines 166 to 167
if (ret)
goto error;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of goto, just handle it directly, wdyt?

if (ret) {
    unregister_chrdev_region(dev, num_of_dev);
    return ret;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

Simplify the init routine by:

- Removing unnecessary temporary variables
- Adding spacing between declarations and statements
- Using early return on alloc_chrdev_region() failure
- Propagating the actual error code instead of always returning -1
- Dropping redundant checks in the error path

This makes the error handling clearer and more consistent with
common kernel coding style.
@jserv jserv merged commit f48df48 into sysprog21:master Sep 3, 2025
1 check passed
@jserv
Copy link
Contributor

jserv commented Sep 3, 2025

Thank @visitorckw 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.

3 participants