Code

git-cvsimport: force checkout of working tree after initial import
[git.git] / sha1_file.c
index 2b860868f55a83ed599f39d7820a9fb227946912..f2b1ae0325ea16e4e46152c3d3d2d3d7f2b32e3d 100644 (file)
@@ -413,7 +413,7 @@ static size_t peak_pack_mapped;
 static size_t pack_mapped;
 struct packed_git *packed_git;
 
-void pack_report()
+void pack_report(void)
 {
        fprintf(stderr,
                "pack_report: getpagesize()            = %10" SZ_FMT "\n"
@@ -510,7 +510,10 @@ static int check_packed_git_idx(const char *path,  struct packed_git *p)
                 * for offsets larger than 2^31.
                 */
                unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;
-               if (idx_size < min_size || idx_size > min_size + (nr - 1)*8) {
+               unsigned long max_size = min_size;
+               if (nr)
+                       max_size += (nr - 1)*8;
+               if (idx_size < min_size || idx_size > max_size) {
                        munmap(idx_map, idx_size);
                        return error("wrong index file size in %s", path);
                }
@@ -959,7 +962,7 @@ int check_sha1_signature(const unsigned char *sha1, void *map, unsigned long siz
        return hashcmp(sha1, real_sha1) ? -1 : 0;
 }
 
-void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
+static void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
 {
        struct stat st;
        void *map;