I’ve been cleaning up a bunch of code lately (including warnings from our forthcoming static analysis tool.)
I’m seeing a bunch of old code that uses integers when “unsigned int” was obviously the intended meaning. For instance:
AddEntriesyToList( ENTRY * pEntry, int cEntries )
There’s realistically no way that you’d ever want to pass a negative number, so DON’T DECLARE IT AS AN INT!!! The same goes for LONGs vs ULONGs, INT_PTR vs UINT_PTR, and so on.
You’ll often know you’re in the presence of this code when you see “%d” used in printf/sprintf string.
I’ve written a lot of code to be cross-CPU compatible, so I’ve become especially attuned to declaring the right data type.
My assertion: all of your integer data types should explicitly be defined as unsigned by default, unless you can articulate why they should be signed.