Monday, January 25, 2010

More on bad embedded software coding and coding practices

Good article here in Electronic Design about litigation that is starting to occur around embedded systems code. Just have a look at this line of code the author of that article found:

y = (x + 305) / 146097 * 400 + (x + 305) % 146097 / 36524 * 100 + (x + 305) % 146097 % 36524 / 1461 * 4 + (x + 305) % 146097 % 36524 % 1461 / 365;

In the original listing, there were no comments on this line to help. I eventually learned that this code computes the year, accounting for extra days in leap years, when given the number of days since a known reference date. But we still don’t know if it works in all cases, despite its presence in an FDA-regulated medical device. The Microsoft Zune Bug was buried in a much better formatted snippet of code that performed a very similar calculation.

This is a follow up to my post about the poor code that TI shipped out with their Zigbee products. I saw posts today that they are shipping updated code, but how long will it take to get it rolled out.

This article really highlights how important good training, good review processes and I think much more open source review is needed as we move forward to the Internet of Things.

No comments:

Post a Comment