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

Merged
merged 1 commit into from
Dec 17, 2024
Merged

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.

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!

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.
@mxinden mxinden marked this pull request as ready for review December 17, 2024 09:42
@djc djc added this pull request to the merge queue Dec 17, 2024
Merged via the queue into quinn-rs:main with commit cb0b59d Dec 17, 2024
18 checks passed
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