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

connect: remove superfluous conditional #7511

Closed

Conversation

danielgustafsson
Copy link
Member

Commit dbd16c3 cleaned up the logic for traversing the addrinfos,
but the move left a conditional on ai which no longer is needed as
the while loop reevaluation will cover it.

Closes #xxxx

Commit dbd16c3 cleaned up the logic for traversing the addrinfos,
but the move left a conditional on ai which no longer is needed as
the while loop reevaluation will cover it.

Closes #xxxx
result = singleipconnect(data, conn, ai, tempindex);
if(result == CURLE_COULDNT_CONNECT) {
ai = ainext(conn, tempindex, TRUE);
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

continue and break could be removed by adding "&& result == CURLE_COULDNT_CONNECT" to the while loop condition

Copy link
Member Author

Choose a reason for hiding this comment

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

It could, but it would have to be a do .. while loop instead as you'd otherwise inspect result before it's been set by the logic in question. Not sure that improves readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

result is already initialized to the right value in line 579, so there is no need to change the loop AFAIK and IMHO makes the code more readable by meaning: "while there are still addresses to check and we hadn't be able to connect do ..."

@danielgustafsson
Copy link
Member Author

danielgustafsson commented Jul 29, 2021 via email

Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

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

👍 on the submitted suggestion. Not convinced about the suggested further cleanup, but shown the suggestion as a PR I might change my mind.

@danielgustafsson
Copy link
Member Author

danielgustafsson commented Jul 30, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants