mirror of
https://github.com/curl/curl.git
synced 2026-06-18 07:45:38 +03:00
src/test: avoid (void)! constructs
The reason to use them seems to be that just (void) before a function call is not enough to silence compiler warnings when return codes are ignored and -Werror=unused-result is used. While (void)! apparently works to silence those warnings, it is just too weird and surprising to readers to use. It is rather a reason to reconsider the usefulness of the warning. Closes #22023
This commit is contained in:
parent
9f25dcea55
commit
c8d8f081fd
2 changed files with 11 additions and 6 deletions
|
|
@ -226,8 +226,10 @@ static char *c_escape(const char *str, curl_off_t len)
|
|||
result = curlx_dyn_addn(&escaped, str, s - str);
|
||||
|
||||
if(!result)
|
||||
(void)!curlx_dyn_addn(&escaped, "...", cutoff);
|
||||
result = curlx_dyn_addn(&escaped, "...", cutoff);
|
||||
|
||||
if(result)
|
||||
return NULL;
|
||||
return curlx_dyn_ptr(&escaped);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -321,12 +321,14 @@ static HWND hidden_main_window = NULL;
|
|||
* Hence, do not call 'logmsg()', and instead use 'open/write/close' to
|
||||
* log errors.
|
||||
*/
|
||||
static size_t useless; /* to silence variable 'rc' set but not used */
|
||||
static void exit_signal_handler(int signum)
|
||||
{
|
||||
int old_errno = errno;
|
||||
size_t rc = 0;
|
||||
if(!serverlogfile) {
|
||||
static const char msg[] = "exit_signal_handler: serverlogfile not set\n";
|
||||
(void)!write(STDERR_FILENO, msg, sizeof(msg) - 1);
|
||||
rc = write(STDERR_FILENO, msg, sizeof(msg) - 1);
|
||||
}
|
||||
else {
|
||||
int fd = -1;
|
||||
|
|
@ -340,14 +342,14 @@ static void exit_signal_handler(int signum)
|
|||
if(fd != -1) {
|
||||
#endif
|
||||
static const char msg[] = "exit_signal_handler: called\n";
|
||||
(void)!write(fd, msg, sizeof(msg) - 1);
|
||||
rc = write(fd, msg, sizeof(msg) - 1);
|
||||
curlx_close(fd);
|
||||
}
|
||||
else {
|
||||
static const char msg[] = "exit_signal_handler: failed opening ";
|
||||
(void)!write(STDERR_FILENO, msg, sizeof(msg) - 1);
|
||||
(void)!write(STDERR_FILENO, serverlogfile, strlen(serverlogfile));
|
||||
(void)!write(STDERR_FILENO, "\n", 1);
|
||||
rc = write(STDERR_FILENO, msg, sizeof(msg) - 1);
|
||||
rc += write(STDERR_FILENO, serverlogfile, strlen(serverlogfile));
|
||||
rc += write(STDERR_FILENO, "\n", 1);
|
||||
}
|
||||
}
|
||||
if(got_exit_signal == 0) {
|
||||
|
|
@ -358,6 +360,7 @@ static void exit_signal_handler(int signum)
|
|||
(void)SetEvent(exit_event);
|
||||
#endif
|
||||
}
|
||||
useless = rc;
|
||||
(void)signal(signum, exit_signal_handler);
|
||||
errno = old_errno;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue