[PATCH v2 0/3] Add stpe*() functions

Alejandro Colomar alx.manpages@gmail.com
Thu Dec 29 10:13:07 GMT 2022


[please CC me]

Hi Zack,

On 12/29/22 01:01, Zack Weinberg via Libc-alpha wrote:
> On Wed, Dec 28, 2022, at 6:17 PM, Alejandro Colomar via Libc-alpha wrote:
>> This version of the patch set adds the [v]stpeprintf() functions, which
>> are more necessary than stpecpy(3).  snprintf(3) is the only way to
>> catenate formatted strings, and it's really bad for that.
> 
> I don't necessarily _oppose_ the addition of these functions but I wonder
> whether the uses you have in mind would be satisfied by open_memstream() +
> fprintf().

There are uses which could be covered by it.  However, several of the cases 
where I found dubious code around snprintf(3) (when not straight bugs) can't use 
it.  Most of the use cases of snprintf(3) were legitimately truncating; for 
example, one of them was creating a path, and anything over PATH_MAX would be an 
error.  In Nginx code, performance also matters a lot, so I guess this function 
has unnecessary overhead due to realloc(3) (although I don't know how much 
that's relevant, since snprintf(3) is already quite slow).

But it's an interesting alternative; thanks!

Cheers,

Alex

> 
> zw

-- 
<http://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20221229/4594266b/attachment.sig>


More information about the Libc-alpha mailing list