diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2009-03-25 14:16:46 -0700 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-03-26 08:53:21 +0100 |
commit | c04cb1274c492344aa0adbe453903a017d33c744 (patch) | |
tree | c6b7f551ea38ad45e8bee7a639d978f710b7cf83 /src/df.c | |
parent | b102ed9ba6e529cc3dcf6be63c95d0f93d5499e0 (diff) | |
download | coreutils-c04cb1274c492344aa0adbe453903a017d33c744.tar.gz coreutils-c04cb1274c492344aa0adbe453903a017d33c744.tar.bz2 coreutils-c04cb1274c492344aa0adbe453903a017d33c744.zip |
df: fix a bug when totaling unknown values
* 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.
Diffstat (limited to 'src/df.c')
-rw-r--r-- | src/df.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -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; + 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; |