Re: Compiler warnings

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiler warnings
Date: 2016-12-06 20:31:16
Message-ID: CA+Tgmoa5UOy=U_jWVyyJcpR4gqWREcq6KUD+afRbrakqyhe9aQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 6, 2016 at 3:23 PM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> * Stephen Frost (sfrost(at)snowman(dot)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.

In LWLockRelease, why not just move mode = held_lwlocks[i].mode; after
the if (i < 0) elog(...), instead of initializing with a bogus value?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2016-12-06 20:32:58 Re: Hash Indexes
Previous Message Andres Freund 2016-12-06 20:27:51 Re: WIP: Faster Expression Processing and Tuple Deforming (including JIT)