tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH 1/6] fix ambiguous errno treating after mktime()



On Thu, Aug 21, 2008 at 8:51 PM, Andy Shevchenko
<andy.shevchenko%gmail.com@localhost> wrote:
>>> The SUSv3 describes errno value only for C extension, but we can reset
>>> errno to drop ambiguous treating its value.
>> I object libc resetting errno.
> Tomorrow I'll try to send here the simple test case to check it.
> May be my test case is wrong.

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

int main()
{
        time_t rc;
        struct tm tms;

        memset(&tms, 0, sizeof(tms));
        tms.tm_year = ~0;

        errno = 0;
        rc = mktime(&tms);

        if (errno != 0)
                printf("mktime(): errno was %d\n", errno);

        return 0;
}


NetBSD:
06:26 tmp$ date && ./mktime-19
Fri Aug 22 06:26:44 UTC 2008
mktime(): errno was 2

Ubuntu Linux:
andy@FITFIESPPC176:~/tmp/posix01-base-ts$ date && ./mktime-19
Fri Aug 22 09:26:20 EEST 2008

-- 
With Best Regards,
Andy Shevchenko


Home | Main Index | Thread Index | Old Index