Commit 6c72a28e authored by Tom Lane's avatar Tom Lane

Suppress -Wunused-result warnings about write(), again.

Adopt the same solution as in commit aa90e148, but this time
let's put the ugliness inside the write_stderr() macro, instead of
expecting each call site to deal with it.  Back-port that decision
into psql/common.c where I got the macro from in the first place.

Per gripe from Peter Eisentraut.
parent e1623c39
...@@ -137,8 +137,18 @@ static volatile DumpSignalInformation signal_info; ...@@ -137,8 +137,18 @@ static volatile DumpSignalInformation signal_info;
static CRITICAL_SECTION signal_info_lock; static CRITICAL_SECTION signal_info_lock;
#endif #endif
/* Used from signal handlers, no buffering */ /*
#define write_stderr(str) write(fileno(stderr), str, strlen(str)) * Write a simple string to stderr --- must be safe in a signal handler.
* We ignore the write() result since there's not much we could do about it.
* Certain compilers make that harder than it ought to be.
*/
#define write_stderr(str) \
do { \
const char *str_ = (str); \
int rc_; \
rc_ = write(fileno(stderr), str_, strlen(str_)); \
(void) rc_; \
} while (0)
#ifdef WIN32 #ifdef WIN32
......
...@@ -235,8 +235,18 @@ static PGcancel *volatile cancelConn = NULL; ...@@ -235,8 +235,18 @@ static PGcancel *volatile cancelConn = NULL;
static CRITICAL_SECTION cancelConnLock; static CRITICAL_SECTION cancelConnLock;
#endif #endif
/* Used from signal handlers, no buffering */ /*
#define write_stderr(str) write(fileno(stderr), str, strlen(str)) * Write a simple string to stderr --- must be safe in a signal handler.
* We ignore the write() result since there's not much we could do about it.
* Certain compilers make that harder than it ought to be.
*/
#define write_stderr(str) \
do { \
const char *str_ = (str); \
int rc_; \
rc_ = write(fileno(stderr), str_, strlen(str_)); \
(void) rc_; \
} while (0)
#ifndef WIN32 #ifndef WIN32
...@@ -245,7 +255,6 @@ static void ...@@ -245,7 +255,6 @@ static void
handle_sigint(SIGNAL_ARGS) handle_sigint(SIGNAL_ARGS)
{ {
int save_errno = errno; int save_errno = errno;
int rc;
char errbuf[256]; char errbuf[256];
/* if we are waiting for input, longjmp out of it */ /* if we are waiting for input, longjmp out of it */
...@@ -262,16 +271,11 @@ handle_sigint(SIGNAL_ARGS) ...@@ -262,16 +271,11 @@ handle_sigint(SIGNAL_ARGS)
if (cancelConn != NULL) if (cancelConn != NULL)
{ {
if (PQcancel(cancelConn, errbuf, sizeof(errbuf))) if (PQcancel(cancelConn, errbuf, sizeof(errbuf)))
{ write_stderr("Cancel request sent\n");
rc = write_stderr("Cancel request sent\n");
(void) rc; /* ignore errors, nothing we can do here */
}
else else
{ {
rc = write_stderr("Could not send cancel request: "); write_stderr("Could not send cancel request: ");
(void) rc; /* ignore errors, nothing we can do here */ write_stderr(errbuf);
rc = write_stderr(errbuf);
(void) rc; /* ignore errors, nothing we can do here */
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment