[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] df: new option: --total (-c) to produce grand total (in the
From: |
Jim Meyering |
Subject: |
Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du) |
Date: |
Wed, 03 Sep 2008 15:00:25 +0200 |
Andreas Schwab <address@hidden> wrote:
> Jim Meyering <address@hidden> writes:
>
>> I presume you're referring to uses of "bool" variables
>> like these (there are many more):
>
> I'm referring to the use of the very same variables that are used in the
> patch. If those are not pure boolean then you have a bug anyway.
By "used in the patch" do you mean "introduced by the patch"?
I see no problem with the new global, print_grand_total,
and none with the parameters to add_uint_with_neg_flag.
Please be precise.
Here are some of the changes needed to protect against the substandard
"bool" problem we're talking about. Some of the changes (& => &&)
are unconditional improvements, imho. However, the others are not.
Before I start polluting the code with those "fixes", I'd like
confirmation that this is a problem in more than just theory. Do any
of you know of "reasonable portability targets" that are affected?
Gnulib's documentation says that these systems lack stdbool.h:
AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1
So they'd use gnulib's replacement.
However, I suspect that most people building on such systems
end up using a working "bool" type, rather than the one warned about
in the code.
diff --git a/src/df.c b/src/df.c
index 0bb3b1e..40d6f71 100644
--- a/src/df.c
+++ b/src/df.c
@@ -185,11 +185,11 @@ print_header (void)
divisible_by_1000 = q1000 % 1000 == 0; q1000 /= 1000;
divisible_by_1024 = q1024 % 1024 == 0; q1024 /= 1024;
}
- while (divisible_by_1000 & divisible_by_1024);
+ while (divisible_by_1000 && divisible_by_1024);
- if (divisible_by_1000 < divisible_by_1024)
+ if (!!divisible_by_1000 < !!divisible_by_1024)
opts |= human_base_1024;
- if (divisible_by_1024 < divisible_by_1000)
+ if (!!divisible_by_1024 < !!divisible_by_1000)
opts &= ~human_base_1024;
if (! (opts & human_base_1024))
opts |= human_B;
@@ -246,7 +246,7 @@ df_readable (bool negative, uintmax_t n, char *buf,
return "-";
else
{
- char *p = human_readable (negative ? -n : n, buf + negative,
+ char *p = human_readable (negative ? -n : n, buf + !!negative,
human_output_opts, input_units, output_units);
if (negative)
*--p = '-';
@@ -323,10 +323,10 @@ show_dev (char const *disk, char const *mount_point,
bool negate_used;
double pct = -1;
- if (me_remote & show_local_fs)
+ if (me_remote && show_local_fs)
return;
- if (me_dummy & !show_all_fs & !show_listed_fs)
+ if (me_dummy && !show_all_fs && !show_listed_fs)
return;
if (!selected_fstype (fstype) || excluded_fstype (fstype))
@@ -419,7 +419,7 @@ show_dev (char const *disk, char const *mount_point,
total = fsu.fsu_blocks;
available = fsu.fsu_bavail;
negate_available = (fsu.fsu_bavail_top_bit_set
- & (available != UINTMAX_MAX));
+ && (available != UINTMAX_MAX));
available_to_root = fsu.fsu_bfree;
grand_fsu.fsu_blocks += input_units * total;
Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du), Kamil Dudka, 2008/09/03