-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Conversation
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ..."
result is already initialized to the right value in line 579, so there is no need to change the loop
It is, but there is no guarantee that there wont be code inserted between there and here which scribbles over result (and which misses to update the loop conditional).
IMHO makes the code more readable by meaning: "while there are still addresses to check and we hadn't be able to connect do ..."
A do .. while loop would satisfy that even better then, since the connection hasn't been attempted at that point.
|
There was a problem hiding this 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.
@bagder approved this pull request.
👍 on the submitted suggestion. Not convinced about the suggested further cleanup, but shown the suggestion as a PR I might change my mind.
Pushed like that.
|
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