Skip site navigation (1)Skip section navigation (2)
References:  <bug-277863-227@https.bugs.freebsd.org/bugzilla/>

| previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277863

Dag-Erling Sm=C3=B8rgrav <des@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|New                         |Closed
         Resolution|---                         |Works As Intended

--- Comment #8 from Dag-Erling Sm=C3=B8rgrav <des@FreeBSD.org> ---
Your code assumes that errno will be unchanged if mktime() succeeds. This is
incorrect.  Here is a better test program:

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

    int
    main(void)
    {
            struct tm tm =3D { .tm_mday =3D 1, .tm_year =3D 69, .tm_yday =
=3D -1 };
            time_t t =3D mktime(&tm);
            if (tm.tm_yday =3D=3D -1) {
                    perror("mktime failed");
                    return 1;
            }
            printf("%04d-%02d-%02d %02d:%02d:%02d %s =3D %ld\n",
                tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
                tm.tm_hour, tm.tm_min, tm.tm_sec, tzname[0],
                (long)t);
            return 0;
    }

If you want to argue that errno _should_ be zero if mktime() succeeds, I in=
vite
you to make that argument to the tzcode maintainers
(https://www.iana.org/time-zones), the Austin Group
(https://www.austingroupbugs.net/), and the C standardization committee
(https://www.open-std.org/jtc1/sc22/wg14/), but please take the time to
familiarize yourself with prior work in this area (notably WG14 N3147) firs=
t.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?>