mirror of
https://github.com/curl/curl.git
synced 2026-06-18 07:35:43 +03:00
tests/servers: do not interpret unlink() retval as errno
In `socksd` and `sws` error messages.
Also:
- show the messages only if `unlink()` failed.
- rename a return code variable and sync a message text for consistency.
Ref: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
Spotted by Copilot in `socksd.c`
Bug: https://github.com/curl/curl/pull/21998#discussion_r3409395013
Follow-up to 80eb71a3f5 #8687
Closes #22005
This commit is contained in:
parent
9972f700a8
commit
d9ea8cdcfa
3 changed files with 13 additions and 15 deletions
|
|
@ -917,11 +917,10 @@ socks5_cleanup:
|
|||
sclose(sock);
|
||||
|
||||
#ifdef USE_UNIX_SOCKETS
|
||||
if(unlink_socket && socket_domain == AF_UNIX && unix_socket) {
|
||||
int error = unlink(unix_socket);
|
||||
logmsg("unlink(%s) = %d (%s)", unix_socket,
|
||||
error, curlx_strerror(error, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
if(unlink_socket && socket_domain == AF_UNIX && unix_socket &&
|
||||
unlink(unix_socket))
|
||||
logmsg("unlink(%s): %d (%s)", unix_socket,
|
||||
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
|
||||
#endif
|
||||
|
||||
if(wrotepidfile)
|
||||
|
|
|
|||
|
|
@ -2442,11 +2442,10 @@ sws_cleanup:
|
|||
sclose(sock);
|
||||
|
||||
#ifdef USE_UNIX_SOCKETS
|
||||
if(unlink_socket && socket_domain == AF_UNIX && unix_socket) {
|
||||
rc = unlink(unix_socket);
|
||||
logmsg("unlink(%s) = %d (%s)", unix_socket,
|
||||
rc, curlx_strerror(rc, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
if(unlink_socket && socket_domain == AF_UNIX && unix_socket &&
|
||||
unlink(unix_socket))
|
||||
logmsg("unlink(%s): %d (%s)", unix_socket,
|
||||
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
|
||||
#endif
|
||||
|
||||
free(req);
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ void set_advisor_read_lock(const char *filename)
|
|||
void clear_advisor_read_lock(const char *filename)
|
||||
{
|
||||
int error = 0;
|
||||
int res;
|
||||
int rc;
|
||||
|
||||
/*
|
||||
* Log all removal failures. Even those due to file not existing.
|
||||
|
|
@ -260,10 +260,10 @@ void clear_advisor_read_lock(const char *filename)
|
|||
*/
|
||||
|
||||
do {
|
||||
res = unlink(filename);
|
||||
rc = unlink(filename);
|
||||
/* !checksrc! disable ERRNOVAR 1 */
|
||||
} while(res && ((error = errno) == EINTR));
|
||||
if(res) {
|
||||
} while(rc && ((error = errno) == EINTR));
|
||||
if(rc) {
|
||||
char errbuf[STRERROR_LEN];
|
||||
logmsg("Error removing lock file %s error (%d) %s", filename,
|
||||
error, curlx_strerror(error, errbuf, sizeof(errbuf)));
|
||||
|
|
@ -716,7 +716,7 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
|
|||
/* dead socket, cleanup and retry bind */
|
||||
rc = unlink(unix_socket);
|
||||
if(rc) {
|
||||
logmsg("Error binding socket, failed to unlink %s (%d) %s", unix_socket,
|
||||
logmsg("Error binding socket, failed to unlink %s: %d (%s)", unix_socket,
|
||||
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue