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

Commitec56223

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 parent4044290 commitec56223

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
@@ -136,8 +136,18 @@ static volatile DumpSignalInformation signal_info;
136136
staticCRITICAL_SECTIONsignal_info_lock;
137137
#endif
138138

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

142152

143153
#ifdefWIN32

‎src/bin/psql/common.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,18 @@ static PGcancel *volatile cancelConn = NULL;
175175
staticCRITICAL_SECTIONcancelConnLock;
176176
#endif
177177

178-
/* Used from signal handlers, no buffering */
179-
#definewrite_stderr(str)write(fileno(stderr), str, strlen(str))
178+
/*
179+
* Write a simple string to stderr --- must be safe in a signal handler.
180+
* We ignore the write() result since there's not much we could do about it.
181+
* Certain compilers make that harder than it ought to be.
182+
*/
183+
#definewrite_stderr(str) \
184+
do { \
185+
const char *str_ = (str); \
186+
intrc_; \
187+
rc_ = write(fileno(stderr), str_, strlen(str_)); \
188+
(void) rc_; \
189+
} while (0)
180190

181191

182192
#ifndefWIN32
@@ -185,7 +195,6 @@ static void
185195
handle_sigint(SIGNAL_ARGS)
186196
{
187197
intsave_errno=errno;
188-
intrc;
189198
charerrbuf[256];
190199

191200
/* if we are waiting for input, longjmp out of it */
@@ -202,16 +211,11 @@ handle_sigint(SIGNAL_ARGS)
202211
if (cancelConn!=NULL)
203212
{
204213
if (PQcancel(cancelConn,errbuf,sizeof(errbuf)))
205-
{
206-
rc=write_stderr("Cancel request sent\n");
207-
(void)rc;/* ignore errors, nothing we can do here */
208-
}
214+
write_stderr("Cancel request sent\n");
209215
else
210216
{
211-
rc=write_stderr("Could not send cancel request: ");
212-
(void)rc;/* ignore errors, nothing we can do here */
213-
rc=write_stderr(errbuf);
214-
(void)rc;/* ignore errors, nothing we can do here */
217+
write_stderr("Could not send cancel request: ");
218+
write_stderr(errbuf);
215219
}
216220
}
217221

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp