mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Yossi Gottlieb <yossigo@gmail.com>
To: musl@lists.openwall.com
Subject: [musl] strftime() unexpectedly modifies errno
Date: Mon, 15 Mar 2021 21:43:36 +0200	[thread overview]
Message-ID: <CAMquMNTmDZnGvtPo3H0Uo-3ytGDO5EHa+RHCBTZTph6c3WFsYA@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2021-03-15 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 19:43 Yossi Gottlieb [this message]
2021-03-15 20:06 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMquMNTmDZnGvtPo3H0Uo-3ytGDO5EHa+RHCBTZTph6c3WFsYA@mail.gmail.com \
    --to=yossigo@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).