X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=read-cache.c;h=ced597318e783ab08b73c88f8b724be51f3b3dec;hb=ff3412ee1f74cc267e6d65c03c5fd8ea2214fbe7;hp=f448ab17e279d2fb4e2cfa91cfc61be6f91128db;hpb=07ee0d77c66d6f356cd3f82435e67510779aa53c;p=git.git diff --git a/read-cache.c b/read-cache.c index f448ab17..ced59731 100644 --- a/read-cache.c +++ b/read-cache.c @@ -191,6 +191,8 @@ int ce_path_match(const struct cache_entry *ce, const char **pathspec) return 1; if (name[matchlen] == '/' || !name[matchlen]) return 1; + if (!matchlen) + return 1; } return 0; } @@ -392,7 +394,7 @@ int read_cache(void) return (errno == ENOENT) ? 0 : error("open failed"); size = 0; // avoid gcc warning - map = (void *)-1; + map = MAP_FAILED; if (!fstat(fd, &st)) { size = st.st_size; errno = EINVAL; @@ -400,7 +402,7 @@ int read_cache(void) map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); } close(fd); - if (-1 == (int)(long)map) + if (map == MAP_FAILED) return error("mmap failed"); hdr = map;