Wednesday, June 30, 2010

Code review log

Recently while doing a peer code review I encountered the following code

m_maxLimit = pow(2, ((sizeof(long int) * 8) -1)) - 1;

This piece was to determine the max limit of a long int, I knew there was a standard way to do this but I could not recollect because I had not written code in the recent times which was dependent on the size of a long int(or any variants).

I fired up the Find Symbol in Visual Assist and typed INT_MAX and found that there is LONG_MAX readily available in “Limits.h”. Hence filed a defect on that piece of code and gave the suggestion to use these values.

The Find Symbol in Visual Assist helps a lot in finding such things.

No comments: