[PATCH 10/16] count-objects: do not use xsize_t when counting object size
- From
Jeff King <peff@peff.net>
- Date
- Oct 3, 2014, 20:31 UTC
- Message-ID
- <20141003203137.GJ16293@peff.net>
- In-Reply-To
- <20141003202045.GA15205@peff.net>
The point of xsize_t is to safely cast an off_t into a size_t (because we are about to mmap). But in count-objects, we are summing the sizes in an off_t. Using xsize_t means that count-objects could fail on a 32-bit system with a 4G object (not likely, as other parts of git would fail, but we should at least be correct here).
Signed-off-by: Jeff King <peff@peff.net> --- I think the on_disk_bytes is a little weird here, too. We count actual disk-usage blocks for loose objects here, which makes sense. But we do _not_ do so for packfiles, or for "garbage" files. Which seems kind of inconsistent.
I kind of doubt anybody cares too much either way, though.
builtin/count-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/count-objects.c b/builtin/count-objects.c index a7f70cb..316a805 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -53,7 +53,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose, if (lstat(path, &st) || !S_ISREG(st.st_mode)) bad = 1; else - (*loose_size) += xsize_t(on_disk_bytes(st)); + (*loose_size) += on_disk_bytes(st); } if (bad) { if (verbose) {
-- 2.1.1.566.gdb1f904