Re: pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>, pgsql-hackers(at)postgresql(dot)org, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
Date: 2013-03-25 15:06:25
Message-ID: 515067F1.7050500@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 25.03.2013 15:36, Tom Lane wrote:
> Heikki Linnakangas<heikki(dot)linnakangas(at)iki(dot)fi> writes:
>> Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
>> Per warning from -Wmissing-format-attribute.
>
> Hm, this is exactly what I removed yesterday, because it makes the build
> fail outright on old gcc:
>
> gcc -O1 -Wall -Wmissing-prototypes -Wpointer-arith -Wformat-security -fno-strict-aliasing -g -I../../../src/interfaces/libpq -I../../../src/include -D_XOPEN_SOURCE_EXTENDED -D_USE_CTYPE_MACROS -c -o pg_dump.o pg_dump.c
> In file included from pg_backup.h:29,
> from pg_backup_archiver.h:32,
> from pg_dump.c:60:
> dumputils.h:48: argument format specified for non-function `on_exit_msg_func'
> make: *** [pg_dump.o] Error 1
>
> Perhaps we have to refactor to avoid the use of a function variable
> here. It didn't seem particularly critical to do it like that rather
> than with, say, a bool.

Hmm. exit_horribly() is also used in pg_dumpall, so if you just put a
call to a function in parallel.c in there, the linker will complain when
linking pg_dumpall.

BTW, we never reset on_exit_msg_func, even after getting out of parallel
mode by calling ParallelBackupEnd(). The Assert in
parallel_exit_msg_func() will fail if it gets called after
ParallelBackupEnd().

The attached seems to work. With this patch, on_exit_msg_func() is gone.
There's a different implementation of exit_horribly for pg_dumpall and
pg_dump/restore. In pg_dumpall, it just calls vwrite_msg(). In
pg_dump/restore's version, the logic from parallel_exit_msg_func() is
moved directly to exit_horribly().

> Or maybe we should turn off that warning. It seems to be leaping to
> conclusions about what the usage of the function variable is.

Oh? Its conclusion seems correct to me: the function variable takes
printf-like arguments.

- Heikki

Attachment Content-Type Size
avoid-printf-like-function-var.patch text/x-diff 6.0 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-03-25 18:37:48 pgsql: Add a server version check to pg_basebackup and pg_receivexlog.
Previous Message Tom Lane 2013-03-25 13:36:18 Re: [COMMITTERS] pgsql: Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.

Browse pgsql-hackers by date

  From Date Subject
Next Message Vibhor Kumar 2013-03-25 15:12:05 Re: pg_dump selectively ignores extension configuration tables
Previous Message Steve Singer 2013-03-25 14:59:21 Re: pg_upgrade segfaults when given an invalid PGSERVICE value