From 0669c9bfac7aead01f1400444e691d542f7645c2 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 1 Jun 2008 21:47:31 -0500 Subject: Use correct C type for file sizes We have been using unsigned long as a file size type for a while, which works but isn't quite correct and could easily break. Worse was probably our use of int in the download callback functions, which could be restrictive for packages > 2GB in size. Switch all file size variables to use off_t, which is the preferred type for file sizes. Note that at least on Linux, all applications compiled against libalpm must now be sure to use large file support, where _FILE_OFFSET_BITS is defined to be 64 or there will be some weird issues that crop up. Signed-off-by: Dan McGee --- lib/libalpm/sync.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/libalpm/sync.c') diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 0d6a6ee3..2dad8bf7 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -22,6 +22,7 @@ #include "config.h" +#include /* off_t */ #include #include #include @@ -385,7 +386,7 @@ static int compute_download_size(pmpkg_t *newpkg) { const char *fname; char *fpath; - unsigned long size = 0; + off_t size = 0; fname = alpm_pkg_get_filename(newpkg); ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1)); @@ -395,8 +396,8 @@ static int compute_download_size(pmpkg_t *newpkg) FREE(fpath); size = 0; } else if(handle->usedelta) { - unsigned long dltsize; - unsigned long pkgsize = alpm_pkg_get_size(newpkg); + off_t dltsize; + off_t pkgsize = alpm_pkg_get_size(newpkg); dltsize = _alpm_shortest_delta_path( alpm_pkg_get_deltas(newpkg), @@ -417,8 +418,8 @@ static int compute_download_size(pmpkg_t *newpkg) size = alpm_pkg_get_size(newpkg); } - _alpm_log(PM_LOG_DEBUG, "setting download size %ld for pkg %s\n", size, - alpm_pkg_get_name(newpkg)); + _alpm_log(PM_LOG_DEBUG, "setting download size %lld for pkg %s\n", + (long long)size, alpm_pkg_get_name(newpkg)); newpkg->download_size = size; return(0); @@ -670,7 +671,7 @@ cleanup: * @param newpkg the new package to upgrade to * @return the size of the download */ -unsigned long SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg) +off_t SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg) { return(newpkg->download_size); } -- cgit v1.2.3