Skip to content

Commit edacfbd

Browse files
authored
Remove unnecessary checks in ftp_fopen_wrapper.c (#10711)
* resource is always non-NULL at this point because we check for NULL right after its creation. * resource->path is always set at this point because of the check right above the code where it's used. It was also confusing to see "/" being considered as a "default".
1 parent 371ae12 commit edacfbd

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ext/standard/ftp_fopen_wrapper.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,7 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char
299299
return stream;
300300

301301
connect_errexit:
302-
if (resource) {
303-
php_url_free(resource);
304-
}
302+
php_url_free(resource);
305303

306304
if (stream) {
307305
php_stream_close(stream);
@@ -916,7 +914,7 @@ static int php_stream_ftp_unlink(php_stream_wrapper *wrapper, const char *url, i
916914
}
917915

918916
/* Attempt to delete the file */
919-
php_stream_printf(stream, "DELE %s\r\n", (resource->path != NULL ? ZSTR_VAL(resource->path) : "/"));
917+
php_stream_printf(stream, "DELE %s\r\n", ZSTR_VAL(resource->path));
920918

921919
result = GET_FTP_RESULT(stream);
922920
if (result < 200 || result > 299) {
@@ -979,7 +977,7 @@ static int php_stream_ftp_rename(php_stream_wrapper *wrapper, const char *url_fr
979977
}
980978

981979
/* Rename FROM */
982-
php_stream_printf(stream, "RNFR %s\r\n", (resource_from->path != NULL ? ZSTR_VAL(resource_from->path) : "/"));
980+
php_stream_printf(stream, "RNFR %s\r\n", ZSTR_VAL(resource_from->path));
983981

984982
result = GET_FTP_RESULT(stream);
985983
if (result < 300 || result > 399) {
@@ -990,7 +988,7 @@ static int php_stream_ftp_rename(php_stream_wrapper *wrapper, const char *url_fr
990988
}
991989

992990
/* Rename TO */
993-
php_stream_printf(stream, "RNTO %s\r\n", (resource_to->path != NULL ? ZSTR_VAL(resource_to->path) : "/"));
991+
php_stream_printf(stream, "RNTO %s\r\n", ZSTR_VAL(resource_to->path));
994992

995993
result = GET_FTP_RESULT(stream);
996994
if (result < 200 || result > 299) {

0 commit comments

Comments
 (0)