Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6c72a28

Browse files
committed
Suppress -Wunused-result warnings about write(), again.
Adopt the same solution as in commitaa90e14, but this timelet's put the ugliness inside the write_stderr() macro, instead ofexpecting each call site to deal with it. Back-port that decisioninto psql/common.c where I got the macro from in the first place.Per gripe from Peter Eisentraut.
1 parente1623c3 commit6c72a28

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

‎src/bin/pg_dump/parallel.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,18 @@ static volatile DumpSignalInformation signal_info;
137137
staticCRITICAL_SECTIONsignal_info_lock;
138138
#endif
139139

140-
/* Used from signal handlers, no buffering */
141-
#definewrite_stderr(str)write(fileno(stderr), str, strlen(str))
140+
/*
141+
* Write a simple string to stderr --- must be safe in a signal handler.
142+
* We ignore the write() result since there's not much we could do about it.
143+
* Certain compilers make that harder than it ought to be.
144+
*/
145+
#definewrite_stderr(str) \
146+
do { \
147+
const char *str_ = (str); \
148+
intrc_; \
149+
rc_ = write(fileno(stderr), str_, strlen(str_)); \
150+
(void) rc_; \
151+
} while (0)
142152

143153

144154
#ifdefWIN32

‎src/bin/psql/common.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,18 @@ static PGcancel *volatile cancelConn = NULL;
235235
staticCRITICAL_SECTIONcancelConnLock;
236236
#endif
237237

238-
/* Used from signal handlers, no buffering */
239-
#definewrite_stderr(str)write(fileno(stderr), str, strlen(str))
238+
/*
239+
* Write a simple string to stderr --- must be safe in a signal handler.
240+
* We ignore the write() result since there's not much we could do about it.
241+
* Certain compilers make that harder than it ought to be.
242+
*/
243+
#definewrite_stderr(str) \
244+
do { \
245+
const char *str_ = (str); \
246+
intrc_; \
247+
rc_ = write(fileno(stderr), str_, strlen(str_)); \
248+
(void) rc_; \
249+
} while (0)
240250

241251

242252
#ifndefWIN32
@@ -245,7 +255,6 @@ static void
245255
handle_sigint(SIGNAL_ARGS)
246256
{
247257
intsave_errno=errno;
248-
intrc;
249258
charerrbuf[256];
250259

251260
/* if we are waiting for input, longjmp out of it */
@@ -262,16 +271,11 @@ handle_sigint(SIGNAL_ARGS)
262271
if (cancelConn!=NULL)
263272
{
264273
if (PQcancel(cancelConn,errbuf,sizeof(errbuf)))
265-
{
266-
rc=write_stderr("Cancel request sent\n");
267-
(void)rc;/* ignore errors, nothing we can do here */
268-
}
274+
write_stderr("Cancel request sent\n");
269275
else
270276
{
271-
rc=write_stderr("Could not send cancel request: ");
272-
(void)rc;/* ignore errors, nothing we can do here */
273-
rc=write_stderr(errbuf);
274-
(void)rc;/* ignore errors, nothing we can do here */
277+
write_stderr("Could not send cancel request: ");
278+
write_stderr(errbuf);
275279
}
276280
}
277281

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp