mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Feature request: strftime() should set errno on failure
@ 2022-07-23  2:09 John Scott
  2022-07-23  2:27 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: John Scott @ 2022-07-23  2:09 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1037 bytes --]


My apologies, I don't have a patch, but I think strftime() should set
errno on failure as POSIX Issue 8 stipulates:
I think this functionality is valuable enough that I'd really love it to
be implemented soon, even if it doesn't make it into the final standard
for whatever reason.

Right now, when one gets a return value of 0, there is no way to
distinguish the buffer being too small from other causes of error, which
means there's no way to tell whether a caller should try reallocating
with a larger buffer. Since strftime() is not snprintf-like (but perhaps
it could be as an extension since passing NULL to strftime is undefined,
not that I'm actually recommending that), there's no way to know how big
of a buffer is big enough. Indeed, it's not even clear if NL_TEXTMAX
applies here.

Setting errno to ERANGE would let the caller know whether a larger
buffer should be tried or if the effort will fruitlessly allocate large
amounts of memory.

Thank you.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-23  2:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-23  2:09 [musl] Feature request: strftime() should set errno on failure John Scott
2022-07-23  2:27 ` Rich Felker
2022-07-23  2:42   ` John Scott

Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).