diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-10-27 10:06:58 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-10-27 10:06:58 +0100 |
commit | ccb1b990b0d105a7a9d7cb4d870d8033c47a69f2 (patch) | |
tree | bd5bcbe3c456fccd56d0165873d2dadfddbc69b2 /src/indexer.c | |
parent | 94f74ad28f191e7dc17ae874c00e3ecd6a80fcf4 (diff) | |
parent | 62e562f92b45b6a9b124452f7de6b9e86a179224 (diff) | |
download | libgit2-development.tar.gz |
Merge pull request #2366 from kitbellew/fix-indexer-mmap-castdevelopment
Fix compiler warning (git_off_t cast to size_t).
Diffstat (limited to 'src/indexer.c')
-rw-r--r-- | src/indexer.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/indexer.c b/src/indexer.c index 25c3d0537..93fe9463a 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -427,15 +427,19 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size) static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size) { git_file fd = idx->pack->mwf.fd; - long page_size = git__page_size(); - git_off_t page_start, page_offset; + size_t page_size; + size_t page_offset; + git_off_t page_start; unsigned char *map_data; git_map map; int error; + if ((error = git__page_size(&page_size)) < 0) + return error; + /* the offset needs to be at the beginning of the a page boundary */ - page_start = (offset / page_size) * page_size; - page_offset = offset - page_start; + page_offset = offset % page_size; + page_start = offset - page_offset; if ((error = p_mmap(&map, page_offset + size, GIT_PROT_WRITE, GIT_MAP_SHARED, fd, page_start)) < 0) return error; |