author | Linus Torvalds <torvalds@linux-foundation.org> | |
Wed, 30 May 2007 17:32:19 +0000 (10:32 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 30 May 2007 22:01:37 +0000 (15:01 -0700) | ||
commit | 192a6be2a77ab3bf446237fdf6575b0aca863d9e | |
tree | 8ee58b598b0abffe78dcf16385320c53b74f4f52 | tree | snapshot |
parent | 7faf068660f0a060066ccbc80f7debbba6bc2d76 | commit | diff |
fix signed range problems with hex conversions
Make hexval_table[] "const". Also make sure that the accessor
function hexval() does not access the table with out-of-range
values by declaring its parameter "unsigned char", instead of
"unsigned int".
With this, gcc can just generate:
movzbl (%rdi), %eax
movsbl hexval_table(%rax),%edx
movzbl 1(%rdi), %eax
movsbl hexval_table(%rax),%eax
sall $4, %edx
orl %eax, %edx
for the code to generate a byte from two hex characters.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Make hexval_table[] "const". Also make sure that the accessor
function hexval() does not access the table with out-of-range
values by declaring its parameter "unsigned char", instead of
"unsigned int".
With this, gcc can just generate:
movzbl (%rdi), %eax
movsbl hexval_table(%rax),%edx
movzbl 1(%rdi), %eax
movsbl hexval_table(%rax),%eax
sall $4, %edx
orl %eax, %edx
for the code to generate a byte from two hex characters.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
cache.h | diff | blob | history | |
sha1_file.c | diff | blob | history |