add __attribute__((noreturn)) to suppress a waring

Started by Itagaki Takahiroabout 15 years ago3 messageshackers
Jump to latest
#1Itagaki Takahiro
itagaki.takahiro@gmail.com

I found the following warning with Fedora 14 / gcc 4.5.1.
----
pg_backup_archiver.c: In function ‘_discoverArchiveFormat’:
pg_backup_archiver.c:1736:11: warning: ‘fh’ may be used uninitialized
in this function
----
To suppress it, I'm thinking to add noreturn to die_horribly().
Any objections? Another solution might be adding a dummy assignment
after calls of die_horribly().

--
Itagaki Takahiro

Attachments:

noreturn.diffapplication/octet-stream; name=noreturn.diffDownload+2-2
#2Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Itagaki Takahiro (#1)
Re: add __attribute__((noreturn)) to suppress a waring

On 24.01.2011 03:42, Itagaki Takahiro wrote:

I found the following warning with Fedora 14 / gcc 4.5.1.
----
pg_backup_archiver.c: In function ‘_discoverArchiveFormat’:
pg_backup_archiver.c:1736:11: warning: ‘fh’ may be used uninitialized
in this function
----
To suppress it, I'm thinking to add noreturn to die_horribly().
Any objections? Another solution might be adding a dummy assignment
after calls of die_horribly().

I added a dummy assignment, that's how we've handled this before in
pg_dump. I guess we could use noreturn, we already use it in pg_re_throw
function. But we also have a dummy exit(1) call in the PG_RE_THROW macro
for non-gcc compilers, so we might need to do that here too.

Thanks!

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Heikki Linnakangas (#2)
Re: add __attribute__((noreturn)) to suppress a waring

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:

On 24.01.2011 03:42, Itagaki Takahiro wrote:

To suppress it, I'm thinking to add noreturn to die_horribly().
Any objections? Another solution might be adding a dummy assignment
after calls of die_horribly().

I added a dummy assignment, that's how we've handled this before in
pg_dump.

We generally do *not* want to depend on noreturn, because it will not
suppress similar warnings in non-gcc compilers. Just add a dummy
initialization, or reorganize the code to avoid the problem.

regards, tom lane