Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH 2/2] read-cache.c: fix timestamp comparison

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:44:07


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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help