Zune Fail – programming bug on 30GB units

Many of you probably heard about the Zune leap year bug. I saw a couple of Zunes with the problem before Microsoft released the official “fix.” On December 31st anyone with a 30GB Zune was annoyed to find it would freeze during start up and become totally unresponsive.  Late in the day Microsoft released a “fix” I hesitate to use that word. They suggested leaving the Zune on the frozen screen (you didn’t have much choice) and letting the battery run dead. Once it ran dead, wait till January 1st to turn it back on and sync it with your computer.

The source for the offending code showed up on several websites last night and I pulled out the function that has the problem. Unless your a programmer (I’m not) or can at least read most code (like me) then it won’t mean anything to you (just smile and nod). But basically on December 31st in a leap year there are 366 days, this code gets stuck in a loop when days equal 366 and there isn’t a graceful error exit. It just keeps telling itself that days equal 366 and it doesn’t know what to do.

This code is for a chip made by a third party, not Microsoft. I keep wondering if other devices have had the same problem.

//----------------------------------------------------------
//
// Function: ConvertDays
//
// Local helper function that split total days since Jan 1, ORIGINYEAR into 
// year, month and day
//
// Parameters:
//
// Returns:
//      Returns TRUE if successful, otherwise returns FALSE.
//
//----------------------------------------------------------
BOOL ConvertDays(UINT32 days, SYSTEMTIME* lpTime)
{
    int dayofweek, month, year;
    UINT8 *month_tab;

    //Calculate current day of the week
    dayofweek = GetDayOfWeek(days);

    year = ORIGINYEAR;

    while (days > 365)
    {
        if (IsLeapYear(year))
        {
            if (days > 366)
            {
                days -= 366;
                year += 1;
            }
        }
        else
        {
            days -= 365;
            year += 1;
        }
    }
This entry was posted in Tech and tagged , , , , .