bug-coreutils
[Top][All Lists]
Advanced

[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: Andreas Schwab
Subject: Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du)
Date: Wed, 03 Sep 2008 15:14:41 +0200
User-agent: Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux)

Jim Meyering <address@hidden> writes:

> 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"?

Those existing variables where more uses are added in the patch.

> @@ -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);

Here divisible_by_1000 and divisible_by_1024 are guaranteed to be pure
boolean.

> @@ -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,

Here negative is guaranteed to be pure boolean.

> @@ -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)

Here me_remote and me_dummy are guaranteed to be pure boolean.

> @@ -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));

Here fsu.fsu_bavail_top_bit_set is guaranteed to be pure boolean.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]