Re: Why the asprintf patch is still breaking the buildfarm

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Manlio Perillo <manlio(dot)perillo(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why the asprintf patch is still breaking the buildfarm
Date: 2013-10-22 15:00:42
Message-ID: 19697.1382454042@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Manlio Perillo <manlio(dot)perillo(at)gmail(dot)com> writes:
> On 22/10/2013 09:58, Tom Lane wrote:
>> 1. src/port/asprintf.c exhibits a truly touching faith that vsnprintf will
>> report exactly the number of bytes that would have been required, even if
>> the buffer is not that large. While this is what is specified in recent
>> versions of the POSIX standard, older platforms have much sketchier
>> behavior.

> Just to be pedantic, this is required by C99.

Yeah. As a separate matter, it might be useful to revise stringinfo.c
and the asprintf code so that *if* the returned value is larger than the
given buffer size, we use it as a guide to resizing, avoiding the possible
need to loop multiple times to make the buffer large enough. And we could
also improve our own implementation of snprintf to follow the C99 spec.

The point here is that we still need to cope with pre-C99 implementations
that might return -1 or the given buffer size on overflow. The NetBSD
implementation doesn't do that, which is reasonable in their context, but
not workable for us.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-10-22 15:02:12 Re: logical changeset generation v6.2
Previous Message Robert Haas 2013-10-22 14:57:11 Re: logical changeset generation v6.4