Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cEMHf-0007ev-IL for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2016 20:24:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cEMHf-0004kh-0D for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2016 20:24:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cEMHd-0004hs-LA for pgsql-hackers@postgresql.org; Tue, 06 Dec 2016 20:24:13 +0000 Received: from tamriel.snowman.net ([72.66.115.51]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cEMHY-0003V4-8c for pgsql-hackers@postgresql.org; Tue, 06 Dec 2016 20:24:12 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id EA4135F7A4; Tue, 6 Dec 2016 15:23:05 -0500 (EST) Date: Tue, 6 Dec 2016 15:23:05 -0500 From: Stephen Frost To: pgsql-hackers@postgresql.org Subject: Re: Compiler warnings Message-ID: <20161206202305.GQ23417@tamriel.snowman.net> References: <20161129152102.GR13284@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="tRcR9GoWqjXrt11v" Content-Disposition: inline In-Reply-To: <20161129152102.GR13284@tamriel.snowman.net> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-91-generic (x86_64) X-Uptime: 15:21:50 up 150 days, 21:46, 29 users, load average: 0.12, 0.04, 0.05 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -4.8 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --tRcR9GoWqjXrt11v Content-Type: multipart/mixed; boundary="1Sa0i77dkqaUxqYg" Content-Disposition: inline --1Sa0i77dkqaUxqYg Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > I'm building with: >=20 > gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 >=20 > .../src/backend/storage/lmgr/lwlock.c: In function =E2=80=98LWLockRelease= =E2=80=99: > .../src/backend/storage/lmgr/lwlock.c:1802:5: warning: =E2=80=98mode=E2= =80=99 may be used uninitialized in this function [-Wmaybe-uninitialized] > if (mode =3D=3D LW_EXCLUSIVE) > ^ > .../src/backend/utils/cache/plancache.c: In function =E2=80=98GetCachedPl= an=E2=80=99: > .../src/backend/utils/cache/plancache.c:1232:9: warning: =E2=80=98plan=E2= =80=99 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 --1Sa0i77dkqaUxqYg Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="silence-warnings_v2.patch" Content-Transfer-Encoding: quoted-printable =46rom afe53a0fa8a53c080b77a7334531ff3a5dc976d4 Mon Sep 17 00:00:00 2001 =46rom: Stephen Frost 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%40= tamriel.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/l= wlock.c index 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 =3D 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 index 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 =3D NULL; List *qlist; bool customplan; =20 --=20 2.7.4 --1Sa0i77dkqaUxqYg-- --tRcR9GoWqjXrt11v Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJYRx4pAAoJEO1sijiDR2RVtQsP/3pzVhhcXvIyP+oV6C9F0cnk XFqN+gD6Ppt5jGb/yXcO9vBT3H8wfaHUY5XkGwUZJxIVbKpXRp8u2n0FPJtTuB80 wzLUdFTsCdNkVSCO81kfbWl4hUsOh7+sAb639bQVTvw6EOc97dqjppfg7Z5ZkRI4 /dwlSlt1x3QalVFNWkSvX96nVKG3qo7H+zY5z/0BmjFFLYLkiYV7xmdram4gISIs Zu+TkYEoXWDmzJoFx0l5zddnuiqIymgfI0jVQVyMMtNgiXXYCJBMst595xy+FU8a ns4XI/ScXHkVxzfoohpLyn5uF+fxRp1mQYAVcSiSihYmQ1c1X4qrOm30AWUkhR2l 5Nj7Rgt+AMpc+55I7XkjT8KOSWCNnM+ZaSIDY/azUpEAnM20mAoj4mO47IvEq8M7 WnrC2+sgitB7bvb7pQ9T6R3AYuMQHZuM7GzmGqHIz93K7gIXooDWwSVZoBzKYl1Z 63f28ndtJBkNS2CIvCRZPxZx29uMDnzZr/M61Jn2FqfdrFTXkyEXJ3qWiD65q3z/ 7kZ6IfLsPjFZYFo2Eds2+fDoH6uc7V8nwK/5j3OnP2ME7IKsJAmZ2mRmp+LoP22t 7SDe4OsHLe2Jn/gczUYi+l4RBPY9wMYuESsAbMUmw1IqtpYgRnt3qxCCqRl20r3H fGuV3pfdWC19phX9Jgfz =bpvG -----END PGP SIGNATURE----- --tRcR9GoWqjXrt11v--