Skip to content

Commit

Permalink
Merge branch 'lt/maint-unsigned-left-shift'
Browse files Browse the repository at this point in the history
* lt/maint-unsigned-left-shift:
  Fix big left-shifts of unsigned char
  • Loading branch information
Junio C Hamano committed Jun 21, 2009
2 parents d4f6bc8 + 48fb7de commit 7c74c39
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
3 changes: 1 addition & 2 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ static struct git_attr *(git_attr_hash[HASHSIZE]);

static unsigned hash_name(const char *name, int namelen)
{
unsigned val = 0;
unsigned char c;
unsigned val = 0, c;

while (namelen--) {
c = *name++;
Expand Down
2 changes: 1 addition & 1 deletion base85.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)
unsigned acc = 0;
int cnt;
for (cnt = 24; cnt >= 0; cnt -= 8) {
int ch = *data++;
unsigned ch = *data++;
acc |= ch << cnt;
if (--bytes == 0)
break;
Expand Down
3 changes: 1 addition & 2 deletions builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,7 @@ static void rehash_objects(void)

static unsigned name_hash(const char *name)
{
unsigned char c;
unsigned hash = 0;
unsigned c, hash = 0;

if (!name)
return 0;
Expand Down
4 changes: 2 additions & 2 deletions builtin-unpack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
static void unpack_one(unsigned nr)
{
unsigned shift;
unsigned char *pack, c;
unsigned long size;
unsigned char *pack;
unsigned long size, c;
enum object_type type;

obj_list[nr].offset = consumed_bytes;
Expand Down
5 changes: 2 additions & 3 deletions delta.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ static inline unsigned long get_delta_hdr_size(const unsigned char **datap,
const unsigned char *top)
{
const unsigned char *data = *datap;
unsigned char cmd;
unsigned long size = 0;
unsigned long cmd, size = 0;
int i = 0;
do {
cmd = *data++;
size |= (cmd & ~0x80) << i;
size |= (cmd & 0x7f) << i;
i += 7;
} while (cmd & 0x80 && data < top);
*datap = data;
Expand Down
6 changes: 3 additions & 3 deletions index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size)

static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_base)
{
unsigned char *p, c;
unsigned long size;
unsigned char *p;
unsigned long size, c;
off_t base_offset;
unsigned shift;
void *data;
Expand All @@ -312,7 +312,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
p = fill(1);
c = *p;
use(1);
size += (c & 0x7fUL) << shift;
size += (c & 0x7f) << shift;
shift += 7;
}
obj->size = size;
Expand Down
2 changes: 1 addition & 1 deletion patch-delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
if (cmd & 0x01) cp_off = *data++;
if (cmd & 0x02) cp_off |= (*data++ << 8);
if (cmd & 0x04) cp_off |= (*data++ << 16);
if (cmd & 0x08) cp_off |= (*data++ << 24);
if (cmd & 0x08) cp_off |= ((unsigned) *data++ << 24);
if (cmd & 0x10) cp_size = *data++;
if (cmd & 0x20) cp_size |= (*data++ << 8);
if (cmd & 0x40) cp_size |= (*data++ << 16);
Expand Down
3 changes: 1 addition & 2 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
unsigned long len, enum object_type *type, unsigned long *sizep)
{
unsigned shift;
unsigned char c;
unsigned long size;
unsigned long size, c;
unsigned long used = 0;

c = buf[used++];
Expand Down

0 comments on commit 7c74c39

Please sign in to comment.