[pacman-dev] [PATCH] Only check diskspace availability if needs more than zero

Dan McGee dpmcgee at gmail.com
Sat Dec 18 13:05:40 EST 2010


On Sat, Dec 18, 2010 at 9:58 AM, Allan McRae <allan at archlinux.org> wrote:
> The amount of diskspace needed for a transaction can be less than
> zero.  Only test this against the available disk space if it is
> positive, which avoids a comparison being made between signed and
> unsigned types (-Wsign-compare).
>
> Signed-off-by: Allan McRae <allan at archlinux.org>

Looks good.

> ---
>  lib/libalpm/diskspace.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
> index cc2e7a9..880df62 100644
> --- a/lib/libalpm/diskspace.c
> +++ b/lib/libalpm/diskspace.c
> @@ -302,7 +302,8 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
>                        _alpm_log(PM_LOG_DEBUG, "partition %s, needed %ld, cushion %ld, free %ld\n",
>                                        data->mount_dir, data->max_blocks_needed, cushion,
>                                        (unsigned long)data->fsp.f_bfree);
> -                       if(data->max_blocks_needed + cushion > data->fsp.f_bfree) {
> +                       if(data->max_blocks_needed + cushion >= 0 &&
> +                          (unsigned long)(data->max_blocks_needed + cushion) > data->fsp.f_bfree) {
>                                abort = 1;
>                        }
>                }
> --
> 1.7.3.3
>
>
>


More information about the pacman-dev mailing list