]> git.ipfire.org Git - thirdparty/git.git/blobdiff - read-cache.c
Merge branch 'jc/post-c89-rules-doc' into maint
[thirdparty/git.git] / read-cache.c
index 32816763bd6dbe3d5e1784b3a39bb8c431ec82f9..93a897f240696c82d45e4189266fe187c58f0b1b 100644 (file)
@@ -549,7 +549,7 @@ static int index_name_stage_pos(const struct index_state *istate, const char *na
        first = 0;
        last = istate->cache_nr;
        while (last > first) {
-               int next = (last + first) >> 1;
+               int next = first + ((last - first) >> 1);
                struct cache_entry *ce = istate->cache[next];
                int cmp = cache_name_stage_compare(name, namelen, stage, ce->name, ce_namelen(ce), ce_stage(ce));
                if (!cmp)
@@ -2140,7 +2140,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
        if (mmap_size < sizeof(struct cache_header) + the_hash_algo->rawsz)
                die(_("%s: index file smaller than expected"), path);
 
-       mmap = xmmap(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0);
+       mmap = xmmap_gently(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0);
        if (mmap == MAP_FAILED)
                die_errno(_("%s: unable to map index file"), path);
        close(fd);