Re: Fix big left-shifts of unsigned char

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 18 Jun 2009, Johannes Schindelin wrote:
> 
> I wonder if there is a mode of 'sparse' which could spot these buggers.

Hmm. A very quick hack gets me (this is _after_ my patch):

	diffcore-delta.c:53:24: warning: Signed left-shift
	diffcore-delta.c:58:21: warning: Signed left-shift
	diffcore-delta.c:88:21: warning: Signed left-shift

which are all of the type "<< alloc_log", and not very interesting.

	read-cache.c:1155:17: warning: Signed left-shift

This one is "real", and I noticed it in my earlier greps, but we don't 
care (it's the CACHE_EXT_TREE/CACHE_EXT() matching, and it's all done in 
"int", and the only case we care about is a non-signed case anyway)

	imap-send.c:785:52: warning: Signed left-shift
	imap-send.c:1190:35: warning: Signed left-shift

These are both "real", but we're only working on "unsigned" so we don't 
really care.

	builtin-rev-list.c:201:21: warning: Signed left-shift

this is exp2i(), and it returns 'int', and wouldn't work for big left 
shifts anyway.

And just to see that my sparse logic actually worked, _without_ the patch 
I sent to fix left-shifts, I got these:

	base85.c:95:38: warning: Signed left-shift		(fixed)
	diffcore-delta.c:53:24: warning: Signed left-shift
	diffcore-delta.c:58:21: warning: Signed left-shift
	diffcore-delta.c:88:21: warning: Signed left-shift
	delta.h:98:42: warning: Signed left-shift		(fixed)
	delta.h:98:42: warning: Signed left-shift		(dup - inline)
	patch-delta.c:47:63: warning: Signed left-shift		(fixed)
	read-cache.c:1155:17: warning: Signed left-shift
	sha1_file.c:1179:39: warning: Signed left-shift		(fixed)
	delta.h:98:42: warning: Signed left-shift		(dup - inline)
	delta.h:98:42: warning: Signed left-shift		(dup - inline)
	imap-send.c:785:52: warning: Signed left-shift
	imap-send.c:1190:35: warning: Signed left-shift
	builtin-rev-list.c:201:21: warning: Signed left-shift
	builtin-unpack-objects.c:441:39: warning: Signed left-shift (fixed)

just to verify that my sparse checker actually found the ones the patch 
modified.

			Linus
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]