Re: pg_upgrade's exec_prog() coding improvement

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade's exec_prog() coding improvement
Date: 2012-08-24 14:30:45
Message-ID: 20120824143045.GA23571@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 24, 2012 at 10:08:58AM -0400, Tom Lane wrote:
> Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> > On 23.08.2012 23:07, Alvaro Herrera wrote:
> >> One problem with this is that I get this warning:
> >> /pgsql/source/HEAD/contrib/pg_upgrade/exec.c: In function ‘s_exec_prog’:
> >> /pgsql/source/HEAD/contrib/pg_upgrade/exec.c:96:2: warning: function might be possible candidate for ‘gnu_printf’ format attribute [-Wmissing-format-attribute]
> >> /pgsql/source/HEAD/contrib/pg_upgrade/exec.c:96:2: warning: function might be possible candidate for ‘gnu_printf’ format attribute [-Wmissing-format-attribute]
> >>
> >> I have no idea how to silence that. Ideas?
>
> > You can do what the warning suggests, and tell the compiler that
> > exec_prog takes printf-like arguments.
>
> exec_prog already has such decoration, and Alvaro's patch doesn't remove
> it. So the question is, exactly what the heck does that warning mean?

It sounds like it is suggestioning to use more specific attribute
decoration. This might be relevant:

http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

-Wmissing-format-attribute
Warn about function pointers that might be candidates for format
attributes. Note these are only possible candidates, not absolute ones.
GCC guesses that function pointers with format attributes that are used
in assignment, initialization, parameter passing or return statements
should have a corresponding format attribute in the resulting type. I.e.
the left-hand side of the assignment or initialization, the type of the
parameter variable, or the return type of the containing function
respectively should also have a format attribute to avoid the warning.

GCC also warns about function definitions that might be candidates
for format attributes. Again, these are only possible candidates. GCC
guesses that format attributes might be appropriate for any function
that calls a function like vprintf or vscanf, but this might not always
be the case, and some functions for which format attributes are
appropriate may not be detected.

and I see this option enabled in configure.in.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-08-24 14:53:36 Re: plperl sigfpe reset can crash the server
Previous Message Tom Lane 2012-08-24 14:10:07 Re: 9.2RC1 wraps this Thursday ...