mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] strftime() unexpectedly modifies errno
@ 2021-03-15 19:43 Yossi Gottlieb
  2021-03-15 20:06 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Yossi Gottlieb @ 2021-03-15 19:43 UTC (permalink / raw)
  To: musl

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

It seems like strftime() unexpectedly modifies errno, which is always set
to EINVAL when it returns. Looks like it's not related to any specific
format.

Here's an example:

#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <errno.h>

int main(int argc, char *argv[])
{
    time_t now = time(NULL);
    struct tm *tm = localtime(&now);
    char buf[100];

    errno = 0;
    size_t len = strftime(buf, sizeof(buf), "%d %b %Y %H:%M:%S.", tm);

    printf("len=%zu\n", len);
    printf("buf=%s\n", buf);
    printf("errno=%d\n", errno);
}

[-- Attachment #2: Type: text/html, Size: 776 bytes --]

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

end of thread, other threads:[~2021-03-15 20:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 19:43 [musl] strftime() unexpectedly modifies errno Yossi Gottlieb
2021-03-15 20:06 ` Rich Felker

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

	https://git.vuxu.org/mirror/musl/

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).