From 49750f15ed2db55247cc03170fec1eed617d9454 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 11 Jul 2018 16:32:10 -0700 Subject: applypatch: Fix the return type of FreeSpaceForFile(). Prior to this CL, FreeSpaceForFile() was returning `size_t`, which may overflow on ILP32 when called on a partition with 4GiB+ free space. Additionally, it was returning static_cast(-1) on error, but the caller in freecache.cpp didn't check for that. This CL changes its return type to `int64_t`, and moves the function into freecache.cpp since there's no external caller. Test: Run recovery_unit_test on marlin. Test: Code search shows no external user of FreeSpaceForFile(). Change-Id: I00f501a057726e1f1ab69f367c46c77b30f2d774 --- applypatch/applypatch.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'applypatch/applypatch.cpp') diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index eb0a2a7b5..13e4b1ae0 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -421,15 +420,6 @@ static size_t FileSink(const unsigned char* data, size_t len, int fd) { return done; } -size_t FreeSpaceForFile(const std::string& filename) { - struct statfs sf; - if (statfs(filename.c_str(), &sf) != 0) { - PLOG(ERROR) << "Failed to statfs " << filename; - return -1; - } - return sf.f_bsize * sf.f_bavail; -} - int CacheSizeCheck(size_t bytes) { if (MakeFreeSpaceOnCache(bytes) < 0) { LOG(ERROR) << "Failed to make " << bytes << " bytes available on /cache"; -- cgit v1.2.3