Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b98fd52

Browse files
committed
Silence -Wunused-result warning in contrib/pg_upgrade.
This is just neatnik-ism, but since we do it for comparable code in elog.c, we may as well do it here.
1 parent aa2b237 commit b98fd52

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

contrib/pg_upgrade/util.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,18 @@ pg_log(eLogType type, char *fmt,...)
8181
/* fopen() on log_opts.internal might have failed, so check it */
8282
if ((type != PG_VERBOSE || log_opts.verbose) && log_opts.internal != NULL)
8383
{
84-
fwrite(message, strlen(message), 1, log_opts.internal);
84+
/*
85+
* There's nothing much we can do about it if fwrite fails, but some
86+
* platforms declare fwrite with warn_unused_result. Do a little
87+
* dance with casting to void to shut up the compiler in such cases.
88+
*/
89+
size_t rc;
90+
91+
rc = fwrite(message, strlen(message), 1, log_opts.internal);
8592
/* if we are using OVERWRITE_MESSAGE, add newline to log file */
8693
if (strchr(message, '\r') != NULL)
87-
fwrite("\n", 1, 1, log_opts.internal);
94+
rc = fwrite("\n", 1, 1, log_opts.internal);
95+
(void) rc;
8896
fflush(log_opts.internal);
8997
}
9098

0 commit comments

Comments
 (0)