Re: compiler warning read_objtype_from_string()

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: compiler warning read_objtype_from_string()
Date: 2016-09-28 16:37:50
Message-ID: 20160928163750.GA346711@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
> I'm getting the following compiler warning (using nondefault
> optimization options):
>
> objectaddress.c: In function 'read_objtype_from_string':
> objectaddress.c:2309:9: error: 'type' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> return type;

Umm. I think it can only be uninitialized if we fall out of the end of
the array, in which case we're supposed to throw the ERROR and never
return. Is that not working?

> The comment for the function says
>
> * Return ObjectType for the given object type as given by
> * getObjectTypeDescription; if no valid ObjectType code exists, but it's a
> * possible output type from getObjectTypeDescription, return -1.
>
> But the claim that it can return -1 does not seem supported by the code.

Actually, it is -- but the -1 value comes from the ObjectType array.
Perhaps the comment should state that explicitely.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2016-09-28 16:38:28 Re: [COMMITTERS] pgsql: pg_ctl: Detect current standby state from pg_control
Previous Message Robert Haas 2016-09-28 16:26:29 Re: "Some tests to cover hash_index"