Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-08-06 20:53:47 +0300
committerJunio C Hamano <gitster@pobox.com>2021-08-11 20:19:56 +0300
commit581a3bb155c157094ca486e3a10c4a9b70c8f650 (patch)
tree201ac43a308a316513b6557610a0adb56e5271d2 /object-file.c
parentdd3c8a72a2eaecf0c752a37e1f4ba4de59818e93 (diff)
object-file: use unsigned arithmetic with bit mask
33f379eee6 (make object_directory.loose_objects_subdir_seen a bitmap, 2021-07-07) replaced a wasteful 256-byte array with a 32-byte array and bit operations. The mask calculation shifts a literal 1 of type int left by anything between 0 and 31. UndefinedBehaviorSanitizer doesn't like that and reports: object-file.c:2477:18: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Make sure to use an unsigned 1 instead to avoid the issue. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/object-file.c b/object-file.c
index 35f3e7e9bb..dcb1859225 100644
--- a/object-file.c
+++ b/object-file.c
@@ -2463,7 +2463,7 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
struct strbuf buf = STRBUF_INIT;
size_t word_bits = bitsizeof(odb->loose_objects_subdir_seen[0]);
size_t word_index = subdir_nr / word_bits;
- size_t mask = 1 << (subdir_nr % word_bits);
+ size_t mask = 1u << (subdir_nr % word_bits);
uint32_t *bitmap;
if (subdir_nr < 0 ||