connect: remove superfluous conditional#7511
connect: remove superfluous conditional#7511danielgustafsson wants to merge 1 commit intocurl:masterfrom
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.
continue and break could be removed by adding "&& result == CURLE_COULDNT_CONNECT" to the while loop condition
There was a problem hiding this comment.
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.
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.
|
bagder
left a comment
There was a problem hiding this comment.
👍 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