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 Tue, Aug 26, 2008 at 01:29:14PM +0200, Joerg Sonnenberger wrote:
> On Fri, Aug 22, 2008 at 09:26:01AM +0300, Andy Shevchenko wrote:
> > 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;
> > }
> 
> What happens here is the internal tzset() call as part of mktime sets
> errno. Given that this is not documented as side effect of tzset, I am
> consider to save and restore errno in tzset_locked and friends.
> 
> Opinions?

The above code is bogus, errno should only be checked if rc is non-zero.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index