https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277863

Dag-Erling Smørgrav <d...@freebsd.org> changed:

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

--- Comment #8 from Dag-Erling Smørgrav <d...@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 = { .tm_mday = 1, .tm_year = 69, .tm_yday = -1 };
            time_t t = mktime(&tm);
            if (tm.tm_yday == -1) {
                    perror("mktime failed");
                    return 1;
            }
            printf("%04d-%02d-%02d %02d:%02d:%02d %s = %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 invite
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) first.

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

Reply via email to