Fix a signed overflow error on i686 with GCC 4.7.0

Not sure why this one wasn't showing up on x86_64, but this fixes the
compile on i686.

    diskspace.c: In function 'calculate_removed_size':
    diskspace.c:247:4: error: assuming signed overflow does not occur when negating a division [-Werror=strict-overflow]
    cc1: all warnings being treated as errors

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2012-04-08 22:32:49 -05:00
parent d158dde30c
commit c27a946769

View file

@ -224,6 +224,7 @@ static int calculate_removed_size(alpm_handle_t *handle,
alpm_mountpoint_t *mp; alpm_mountpoint_t *mp;
struct stat st; struct stat st;
char path[PATH_MAX]; char path[PATH_MAX];
blkcnt_t remove_size;
const char *filename = file->name; const char *filename = file->name;
snprintf(path, PATH_MAX, "%s%s", handle->root, filename); snprintf(path, PATH_MAX, "%s%s", handle->root, filename);
@ -243,8 +244,8 @@ static int calculate_removed_size(alpm_handle_t *handle,
} }
/* the addition of (divisor - 1) performs ceil() with integer division */ /* the addition of (divisor - 1) performs ceil() with integer division */
mp->blocks_needed -= remove_size = (st.st_size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize;
(st.st_size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize; mp->blocks_needed -= remove_size;
mp->used |= USED_REMOVE; mp->used |= USED_REMOVE;
} }
@ -265,6 +266,7 @@ static int calculate_installed_size(alpm_handle_t *handle,
const alpm_file_t *file = filelist->files + i; const alpm_file_t *file = filelist->files + i;
alpm_mountpoint_t *mp; alpm_mountpoint_t *mp;
char path[PATH_MAX]; char path[PATH_MAX];
blkcnt_t install_size;
const char *filename = file->name; const char *filename = file->name;
/* libarchive reports these as zero size anyways */ /* libarchive reports these as zero size anyways */
@ -289,8 +291,8 @@ static int calculate_installed_size(alpm_handle_t *handle,
} }
/* the addition of (divisor - 1) performs ceil() with integer division */ /* the addition of (divisor - 1) performs ceil() with integer division */
mp->blocks_needed += install_size = (file->size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize;
(file->size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize; mp->blocks_needed += install_size;
mp->used |= USED_INSTALL; mp->used |= USED_INSTALL;
} }