prewarm compiler warnings

Started by Erik Rijkersabout 7 years ago2 messages
#1Erik Rijkers
er@xs4all.nl
1 attachment(s)

gcc-6.3.0 complains about this:

autoprewarm.c: In function ‘autoprewarm_main’:
autoprewarm.c:210:9: warning: variable ‘rc’ set but not used
[-Wunused-but-set-variable]
int rc;

The warning comes only in master.

The warnings are a bit annoying; the attached silences them by removing
those assignments.

Thanks,

Erik Rijkers

Attachments:

prewarm-fix.difftext/x-diff; name=prewarm-fix.diffDownload
--- ./contrib/pg_prewarm/autoprewarm.c.orig	2018-11-23 13:34:08.237110218 +0100
+++ ./contrib/pg_prewarm/autoprewarm.c	2018-11-23 13:34:38.333492968 +0100
@@ -207,8 +207,6 @@
 	/* Periodically dump buffers until terminated. */
 	while (!got_sigterm)
 	{
-		int			rc;
-
 		/* In case of a SIGHUP, just reload the configuration. */
 		if (got_sighup)
 		{
@@ -219,7 +217,7 @@
 		if (autoprewarm_interval <= 0)
 		{
 			/* We're only dumping at shutdown, so just wait forever. */
-			rc = WaitLatch(&MyProc->procLatch,
+			WaitLatch(&MyProc->procLatch,
 						   WL_LATCH_SET | WL_EXIT_ON_PM_DEATH,
 						   -1L,
 						   PG_WAIT_EXTENSION);
@@ -248,7 +246,7 @@
 			}
 
 			/* Sleep until the next dump time. */
-			rc = WaitLatch(&MyProc->procLatch,
+			WaitLatch(&MyProc->procLatch,
 						   WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
 						   delay_in_ms,
 						   PG_WAIT_EXTENSION);
#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Erik Rijkers (#1)
Re: prewarm compiler warnings

On 2018-Nov-23, Erik Rijkers wrote:

gcc-6.3.0 complains about this:

autoprewarm.c: In function ‘autoprewarm_main’:
autoprewarm.c:210:9: warning: variable ‘rc’ set but not used
[-Wunused-but-set-variable]
int rc;

The warning comes only in master.

Yeah, it's fairly new. I noticed a couple of other places that could
use the same adjustment and pushed them all together. (I used a cast to
void as all other places do that, which appeases Coverity about the
discrepancy.)

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services