Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor(udp): remove unnecessary return #2080

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mxinden
Copy link
Collaborator

@mxinden mxinden commented Dec 13, 2024

No need to return Ok(()) early, given the final return Ok(()) at the end of the function. Makes it consistent with other send implementations. Makes it consistent with early returns being errors only.

Follow-up to #2074 (comment). I have not yet been able to come up with a better refactoring.

No need to `return Ok(())` early, given the final `return Ok(())` at the end of
the function. Makes it consistent with other `send` implementations. Makes it
consistent with early returns being errors only.
Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

I don't think this is equivalent. If sendmsg fails with EMSGSIZE, then with this change the loop will continue rather than bailing out with success.

@mxinden
Copy link
Collaborator Author

mxinden commented Dec 14, 2024

If it fails with EMSGSIZE it will exit the match e.kind() closure:

match e.kind() {

Then exit the if n == -1 closure:

if n == -1 {

But before looping again:

It would return Ok(()) at the end of the loop iteration:

return Ok(());

@Ralith am I missing something?

Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Ah, you're right, miscounted the brackets. Thanks!

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