[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] df: Fix bug when totaling unknown values.
From: |
Jim Meyering |
Subject: |
Re: [PATCH] df: Fix bug when totaling unknown values. |
Date: |
Wed, 25 Mar 2009 23:02:07 +0100 |
Paul Eggert wrote:
> This fixes a bug reported by "make check" on a Solaris 10 host with
> some funky file systems.
>
> * src/df.c (show_dev): Don't add UINTMAX_MAX to grand totals, as that
> value indicates that the true value is unknown; adding it effectively
> subtracts 1 from the total, whereas we want to leave the total alone.
> ---
> src/df.c | 19 ++++++++++++-------
> 1 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/src/df.c b/src/df.c
> index 0bb3b1e..bb24934 100644
> --- a/src/df.c
> +++ b/src/df.c
> @@ -393,8 +393,10 @@ show_dev (char const *disk, char const *mount_point,
> negate_available = false;
> available_to_root = available;
>
> - grand_fsu.fsu_files += total;
> - grand_fsu.fsu_ffree += available;
Good timing.
Matthew Woehlke recently reported failure of the df/total-verify test.
Looking into it, we found that one of those values was UINTMAX_MAX - 1.
So how about a function like summable (uintmax_t val) to be used
in place of each of those 5 tests?
> + if (total != UINTMAX_MAX)
> + grand_fsu.fsu_files += total;
> + if (available != UINTMAX_MAX)
> + grand_fsu.fsu_ffree += available;
> }
> else
> {
> @@ -422,11 +424,14 @@ show_dev (char const *disk, char const *mount_point,
> & (available != UINTMAX_MAX));
> available_to_root = fsu.fsu_bfree;
>
> - grand_fsu.fsu_blocks += input_units * total;
> - grand_fsu.fsu_bfree += input_units * available_to_root;
> - add_uint_with_neg_flag (&grand_fsu.fsu_bavail,
> - &grand_fsu.fsu_bavail_top_bit_set,
> - input_units * available, negate_available);
> + if (total != UINTMAX_MAX)
> + grand_fsu.fsu_blocks += input_units * total;
> + if (available_to_root != UINTMAX_MAX)
> + grand_fsu.fsu_bfree += input_units * available_to_root;
> + if (available != UINTMAX_MAX)
> + add_uint_with_neg_flag (&grand_fsu.fsu_bavail,
> + &grand_fsu.fsu_bavail_top_bit_set,
> + input_units * available, negate_available);
> }
>
> used = UINTMAX_MAX;
Re: [PATCH] df: Fix bug when totaling unknown values., Matthew Woehlke, 2009/03/25