]> granicus.if.org Git - postgresql/commitdiff
Silence -Wunused-result warning in contrib/pg_upgrade.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 5 Sep 2012 18:36:47 +0000 (14:36 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 5 Sep 2012 18:37:22 +0000 (14:37 -0400)
This is just neatnik-ism, but since we do it for comparable code in elog.c,
we may as well do it here.

contrib/pg_upgrade/util.c

index 2c0dfd65e4e970878fe8ed6d7a8522ed67a9187d..d879e762fa24915c4686fd7557770c1fb8efb099 100644 (file)
@@ -81,10 +81,18 @@ pg_log(eLogType type, char *fmt,...)
        /* fopen() on log_opts.internal might have failed, so check it */
        if ((type != PG_VERBOSE || log_opts.verbose) && log_opts.internal != NULL)
        {
-               fwrite(message, strlen(message), 1, log_opts.internal);
+               /*
+                * There's nothing much we can do about it if fwrite fails, but some
+                * platforms declare fwrite with warn_unused_result.  Do a little
+                * dance with casting to void to shut up the compiler in such cases.
+                */
+               size_t          rc;
+
+               rc = fwrite(message, strlen(message), 1, log_opts.internal);
                /* if we are using OVERWRITE_MESSAGE, add newline to log file */
                if (strchr(message, '\r') != NULL)
-                       fwrite("\n", 1, 1, log_opts.internal);
+                       rc = fwrite("\n", 1, 1, log_opts.internal);
+               (void) rc;
                fflush(log_opts.internal);
        }