path: root/index-pack.c
diff options
authorNicolas Pitre <>2007-04-09 05:06:29 (GMT)
committerJunio C Hamano <>2007-04-10 19:48:14 (GMT)
commit8723f216263ba4a0f06be7b93fada863c0931e09 (patch)
tree6d357724c891ce009a8c7ae1a0a4083bc39ff1f5 /index-pack.c
parent57059091fad25427bce9b3d47e073ce0518d164b (diff)
make overflow test on delta base offset work regardless of variable size
This patch introduces the MSB() macro to obtain the desired number of most significant bits from a given variable independently of the variable type. It is then used to better implement the overflow test on the OBJ_OFS_DELTA base offset variable with the property of always working correctly regardless of the type/size of that variable. Signed-off-by: Nicolas Pitre <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'index-pack.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/index-pack.c b/index-pack.c
index 3c768fb..0e54aa6 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -249,7 +249,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
base_offset = c & 127;
while (c & 128) {
base_offset += 1;
- if (!base_offset || base_offset & ~(~0UL >> 7))
+ if (!base_offset || MSB(base_offset, 7))
bad_object(obj->offset, "offset value overflow for delta base object");
p = fill(1);
c = *p;