Re: -Wformat-zero-length - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: -Wformat-zero-length
Date
Msg-id 20120803164435.GA3463@momjian.us
Whole thread Raw
In response to Re: -Wformat-zero-length  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: -Wformat-zero-length
List pgsql-hackers
On Thu, Jul  7, 2011 at 06:09:54PM -0400, Tom Lane wrote:
> I wrote:
> > Peter Eisentraut <peter_e@gmx.net> writes:
> >> I was adding gcc printf attributes to more functions in obscure places,
> >> and now I'm seeing this in pg_upgrade:
>
> >> relfilenode.c:72:2: warning: zero-length gnu_printf format string [-Wformat-zero-length]
>
> > Shouldn't it be prep_status("\n")?  If not, why not?
>
> On closer inspection, it appears to me that prep_status should never be
> called with a string containing a newline, period, and the test it
> contains for that case is just brain damage.  The only reason to call it
> at all is to produce a line like
>
>     message ......................
>
> where something more is expected to be added to the line later.  Calls
> that are meant to produce a complete line could go directly to pg_log.
>
> This in turn implies that transfer_all_new_dbs's use of the function is
> broken and needs to be rethought.

I changed a prep_status() call to pg_log() as you suggested, and
backpatched to 9.2.  Patch attached.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

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

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: CreateLockFile() race condition
Next
From: Andrew Dunstan
Date:
Subject: Re: WIP pgindent replacement