Greetings,

Not sure if anyone else has been seeing these, but I'm getting a bit
tired of them.  Neither is a live bug, but they also seem pretty simple
to fix.  The attached patch makes both of these warnings go away.  At
least for my common build, these are the only warnings that are thrown.

I'm building with:

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

.../src/backend/storage/lmgr/lwlock.c: In function ‘LWLockRelease’:
.../src/backend/storage/lmgr/lwlock.c:1802:5: warning: ‘mode’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]
  if (mode == LW_EXCLUSIVE)
     ^
.../src/backend/utils/cache/plancache.c: In function ‘GetCachedPlan’:
.../src/backend/utils/cache/plancache.c:1232:9: warning: ‘plan’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]
  return plan;
         ^

Thoughts?

Thanks!

Stephen
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
new file mode 100644
index 9c6862f..909ff45
*** a/src/backend/storage/lmgr/lwlock.c
--- b/src/backend/storage/lmgr/lwlock.c
*************** LWLockUpdateVar(LWLock *lock, uint64 *va
*** 1770,1776 ****
  void
  LWLockRelease(LWLock *lock)
  {
! 	LWLockMode	mode;
  	uint32		oldstate;
  	bool		check_waiters;
  	int			i;
--- 1770,1776 ----
  void
  LWLockRelease(LWLock *lock)
  {
! 	LWLockMode	mode = LW_EXCLUSIVE;
  	uint32		oldstate;
  	bool		check_waiters;
  	int			i;
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
new file mode 100644
index 884cdab..b5d97c8
*** a/src/backend/utils/cache/plancache.c
--- b/src/backend/utils/cache/plancache.c
*************** GetCachedPlan(CachedPlanSource *plansour
*** 1196,1204 ****
  			 */
  			qlist = NIL;
  		}
! 	}
! 
! 	if (customplan)
  	{
  		/* Build a custom plan */
  		plan = BuildCachedPlan(plansource, qlist, boundParams);
--- 1196,1203 ----
  			 */
  			qlist = NIL;
  		}
! 	} 
! 	else
  	{
  		/* Build a custom plan */
  		plan = BuildCachedPlan(plansource, qlist, boundParams);

Attachment: signature.asc
Description: Digital signature

Reply via email to