ext/ftp: declare the false returned by ftp_nb_fget() and ftp_nb_fput() - #23540
Open
lacatoire wants to merge 1 commit into
Open
ext/ftp: declare the false returned by ftp_nb_fget() and ftp_nb_fput()#23540lacatoire wants to merge 1 commit into
lacatoire wants to merge 1 commit into
Conversation
Both answer an already busy connection with a warning and RETURN_FALSE, the same guard ftp_nb_get() and ftp_nb_put() have, and those two already declare int|false.
Member
|
Perhaps the code should be revised to throw an Error rather than returning false. Generally, Error is used to indicate a programming mistake, and this is the case here. I believe that's more appropriate than widening the return type |
Member
|
cc @iliaal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ftp_nb_fget()andftp_nb_fput()are declaredint, but both answer an already busy connection withfalse:ftp_nb_get()andftp_nb_put()carry the same guard and already declareint|false; the two stream variants were left behind. Internal functions do not coerce their return value, so a caller hitting the guard receivesfalseagainst a declaration promisingint, and=== FTP_FAILED(integer 0) does not match it.ftp_nb_continue()has no such guard — every exit is aRETURN_LONG— so it staysint.Only the declarations change.
in_useis set and cleared within a single engine call, so the guard is reachable through re-entrancy alone and nothing at runtime moves. The added test reads the declared types of all fiveftp_nb_*functions and needs no FTP server.