From: Stephen Frost <sfrost@snowman.net>
To: pgsql-hackers@postgresql.org
Subject: Re: Compiler warnings
Date: Tue, 6 Dec 2016 15:23:05 -0500
Message-ID: <20161206202305.GQ23417@tamriel.snowman.net> (raw)
In-Reply-To: <20161129152102.GR13284@tamriel.snowman.net>
References: <20161129152102.GR13284@tamriel.snowman.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
All,
* Stephen Frost (sfrost@snowman.net) wrote:
> 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;
> ^
Given the lack of screaming, I'll push the attached in a bit, which just
initializes the two variables being complained about. As mentioned,
there doesn't appear to be any live bugs here, this is just to silence
the compiler warnings.
Thanks!
Stephen
Attachments:
[text/x-diff] silence-warnings_v2.patch (1.5K, ../20161206202305.GQ23417@tamriel.snowman.net/2-silence-warnings_v2.patch)
download | inline diff:
From afe53a0fa8a53c080b77a7334531ff3a5dc976d4 Mon Sep 17 00:00:00 2001
From: Stephen Frost <sfrost@snowman.net>
Date: Tue, 6 Dec 2016 15:19:09 -0500
Subject: [PATCH] Silence compiler warnings
Initialize a couple of variables to silence compiler warnings. There
aren't any cases where these variables could actually end up being used
while uninitialized, but at least gcc 5.4.0-6ubuntu1~16.04.4 doesn't
quite have the smarts to realize that.
Discussion: https://www.postgresql.org/message-id/20161129152102.GR13284%40tamriel.snowman.net
---
src/backend/storage/lmgr/lwlock.c | 2 +-
src/backend/utils/cache/plancache.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.cindex 9c6862f..909ff45 100644--- a/src/backend/storage/lmgr/lwlock.c+++ b/src/backend/storage/lmgr/lwlock.c@@ -1770,7 +1770,7 @@ LWLockUpdateVar(LWLock *lock, uint64 *valptr, uint64 val)
void
LWLockRelease(LWLock *lock)
{
- LWLockMode mode;+ 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.cindex 884cdab..a37074b 100644--- a/src/backend/utils/cache/plancache.c+++ b/src/backend/utils/cache/plancache.c@@ -1128,7 +1128,7 @@ CachedPlan *
GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams,
bool useResOwner)
{
- CachedPlan *plan;+ CachedPlan *plan = NULL;
List *qlist;
bool customplan;
--
2.7.4
[application/pgp-signature] signature.asc (818B, ../20161206202305.GQ23417@tamriel.snowman.net/3-signature.asc)
download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: sfrost@snowman.net
Subject: Re: Compiler warnings
In-Reply-To: <20161206202305.GQ23417@tamriel.snowman.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox