]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diffcore-delta.c: LLP64 compatibility, upcast unity for left shift
authorPhilip Oakley <philipoakley@iee.email>
Wed, 1 Dec 2021 00:29:01 +0000 (00:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Dec 2021 22:48:10 +0000 (14:48 -0800)
Visual Studio reports C4334 "was 64-bit shift intended" warning
because of size miss-match.

Promote unity to the matching type to fit with its subsequent operation.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-delta.c

index 5668ace60d6012d1b91e5359975aaec0df8d5b34..18d8f766d70108e868a5bb21ad6c45550bb8c34d 100644 (file)
@@ -133,10 +133,10 @@ static struct spanhash_top *hash_chars(struct repository *r,
 
        i = INITIAL_HASH_SIZE;
        hash = xmalloc(st_add(sizeof(*hash),
-                             st_mult(sizeof(struct spanhash), 1<<i)));
+                             st_mult(sizeof(struct spanhash), (size_t)1 << i)));
        hash->alloc_log2 = i;
        hash->free = INITIAL_FREE(i);
-       memset(hash->data, 0, sizeof(struct spanhash) * (1<<i));
+       memset(hash->data, 0, sizeof(struct spanhash) * ((size_t)1 << i));
 
        n = 0;
        accum1 = accum2 = 0;
@@ -159,7 +159,7 @@ static struct spanhash_top *hash_chars(struct repository *r,
                n = 0;
                accum1 = accum2 = 0;
        }
-       QSORT(hash->data, 1ul << hash->alloc_log2, spanhash_cmp);
+       QSORT(hash->data, (size_t)1ul << hash->alloc_log2, spanhash_cmp);
        return hash;
 }