On Tue, 22 Jan 2008, Junio C Hamano wrote:
Linus Torvalds [off-list ref] writes:
quoted
The stupid thing is that I literally _grepped_ for the code testing
"ce_mode".
I had missed that one because I had looked for things like
if ([!].*ce_mode)
but that switch statement meant that the comparison to zero was
non-local and my grep didn't see it.
Would a patch to sparse help you in cases like this?
Heh. Sparse can do anything, but some things are more specialized than
others. In this case, I could possibly have added a type modifier that
says "don't compare against zero", and that kind of thing may even make
sense (ie you can mark pointers that are known not to be NULL), and yes,
it would have caught this.
But sparse right now doesn't have that kind of flag (the "safe expression"
thing comes pretty close).
So yes, sparse could do things like this, but it's generally a fair amount
of work to add specialized sparse rules.
Linus