diff options
author | Rose <83477269+AtariDreams@users.noreply.github.com> | 2022-10-28 12:32:09 -0400 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2022-11-08 03:11:01 -0500 |
commit | f151ec6c1053826bdcc740d97257d877b759e777 (patch) | |
tree | 6da9daa805268783d6b3fb75dde3cb5007ab4fb9 /lib/ftp.c | |
parent | 14061f784c47069d20d17dd9d6c6cf4613efeca5 (diff) | |
download | curl-f151ec6c1053826bdcc740d97257d877b759e777.tar.gz |
lib: fix some type mismatches and remove unneeded typecasts
Many of these castings are unneeded if we change the variables to work
better with each other.
Ref: https://github.com/curl/curl/pull/9823
Closes https://github.com/curl/curl/pull/9835
Diffstat (limited to 'lib/ftp.c')
-rw-r--r-- | lib/ftp.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1174,7 +1174,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, /* get the name again after the bind() so that we can extract the port number it uses now */ sslen = sizeof(ss); - if(getsockname(portsock, (struct sockaddr *)sa, &sslen)) { + if(getsockname(portsock, sa, &sslen)) { failf(data, "getsockname() failed: %s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer))); Curl_closesocket(data, conn, portsock); @@ -1950,7 +1950,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data, */ const char * const host_name = conn->bits.socksproxy ? conn->socks_proxy.host.name : conn->http_proxy.host.name; - rc = Curl_resolv(data, host_name, (int)conn->port, FALSE, &addr); + rc = Curl_resolv(data, host_name, conn->port, FALSE, &addr); if(rc == CURLRESOLV_PENDING) /* BLOCKING, ignores the return code but 'addr' will be NULL in case of failure */ @@ -4167,7 +4167,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data) /* get path before last slash, except for / */ size_t dirlen = slashPos - rawPath; if(dirlen == 0) - dirlen++; + dirlen = 1; ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0])); if(!ftpc->dirs) { @@ -4194,13 +4194,14 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data) /* current position: begin of next path component */ const char *curPos = rawPath; - int dirAlloc = 0; /* number of entries allocated for the 'dirs' array */ + /* number of entries allocated for the 'dirs' array */ + size_t dirAlloc = 0; const char *str = rawPath; for(; *str != 0; ++str) if (*str == '/') ++dirAlloc; - if(dirAlloc > 0) { + if(dirAlloc) { ftpc->dirs = calloc(dirAlloc, sizeof(ftpc->dirs[0])); if(!ftpc->dirs) { free(rawPath); @@ -4230,7 +4231,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data) curPos = slashPos + 1; } } - DEBUGASSERT(ftpc->dirdepth <= dirAlloc); + DEBUGASSERT((size_t)ftpc->dirdepth <= dirAlloc); fileName = curPos; /* the rest is the file name (or empty) */ } break; |