View Single Post
Old 01-01-2009, 01:14 PM   #49 (permalink)
tropstorm
Zewbie
 
Join Date: Jan 2009
Posts: 1
tropstorm is on a distinguished road
Default

Quote:
Originally Posted by twhoffman View Post
That would prevent the infinite loop, but would introduce a new bug where it advances the year on the last day of a leap year. It would have thought today was December 31, 2009. That's better than locking up, but it also would mean that all time-limited DRM media would stop working. So, if you have a Zune Pass, none of your songs would play.

What's needed is a break within an else like this (I hope, my C's a little rusty, and was never that good to begin with):

Code:
year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
        else
        {
            break;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}
Yup, you are probably correct. But I think that this whole error is even simpler than people make it out to be and appears to just be either a. a copy/paste error or b. a bug that was only fixed in one place and not the other. Check out the "MX31GetRealTime" function in the original code posted. It has the correct implementation with the else and break already. So I am guessing when this code was pasted, and this bug fixed, it only got fixed in one location.



tropstorm is offline   Reply With Quote