Skip to content

Commit cb136bd

Browse files
committed
Merge branch 'po/size-t-for-vs'
On platforms where ulong is shorter than size_t, code paths that shifted 1 or 1U to the left lacked the necessary cast to size_t, which have been corrected. * po/size-t-for-vs: object-file.c: LLP64 compatibility, upcast unity for left shift diffcore-delta.c: LLP64 compatibility, upcast unity for left shift repack.c: LLP64 compatibility, upcast unity for left shift
2 parents fc0e3e0 + 26de1fc commit cb136bd

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

builtin/repack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
844844
fname_old = mkpathdup("%s-%s%s",
845845
packtmp, item->string, exts[ext].name);
846846

847-
if (((uintptr_t)item->util) & (1 << ext)) {
847+
if (((uintptr_t)item->util) & ((uintptr_t)1 << ext)) {
848848
struct stat statbuffer;
849849
if (!stat(fname_old, &statbuffer)) {
850850
statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);

diffcore-delta.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ static struct spanhash_top *hash_chars(struct repository *r,
133133

134134
i = INITIAL_HASH_SIZE;
135135
hash = xmalloc(st_add(sizeof(*hash),
136-
st_mult(sizeof(struct spanhash), 1<<i)));
136+
st_mult(sizeof(struct spanhash), (size_t)1 << i)));
137137
hash->alloc_log2 = i;
138138
hash->free = INITIAL_FREE(i);
139-
memset(hash->data, 0, sizeof(struct spanhash) * (1<<i));
139+
memset(hash->data, 0, sizeof(struct spanhash) * ((size_t)1 << i));
140140

141141
n = 0;
142142
accum1 = accum2 = 0;
@@ -159,7 +159,7 @@ static struct spanhash_top *hash_chars(struct repository *r,
159159
n = 0;
160160
accum1 = accum2 = 0;
161161
}
162-
QSORT(hash->data, 1ul << hash->alloc_log2, spanhash_cmp);
162+
QSORT(hash->data, (size_t)1ul << hash->alloc_log2, spanhash_cmp);
163163
return hash;
164164
}
165165

object-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2425,7 +2425,7 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
24252425
struct strbuf buf = STRBUF_INIT;
24262426
size_t word_bits = bitsizeof(odb->loose_objects_subdir_seen[0]);
24272427
size_t word_index = subdir_nr / word_bits;
2428-
size_t mask = 1u << (subdir_nr % word_bits);
2428+
size_t mask = (size_t)1u << (subdir_nr % word_bits);
24292429
uint32_t *bitmap;
24302430

24312431
if (subdir_nr < 0 ||

0 commit comments

Comments
 (0)