Re: compiler warning read_objtype_from_string() - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: compiler warning read_objtype_from_string()
Date
Msg-id 20160928163750.GA346711@alvherre.pgsql
Whole thread Raw
In response to compiler warning read_objtype_from_string()  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: compiler warning read_objtype_from_string()  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: "Some tests to cover hash_index"
Next
From: Peter Eisentraut
Date:
Subject: Re: [COMMITTERS] pgsql: pg_ctl: Detect current standby state from pg_control