Re: [patch 04/91] proc: save LOC in __xlate_proc_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 6, 2021 at 6:02 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> From: Alexey Dobriyan <adobriyan@xxxxxxxxx>
> Subject: proc: save LOC in __xlate_proc_name()
..
> +       while ((next = strchr(cp, '/'))) {

Please don't do this.

Yes, gcc suggests that double parentheses syntax around an assignment
to avoid warnings.

gcc is wrong, and is being completely stupid.

The proper way to avoid the "assignment in conditional" warning is to
(surprise, surprise) USE A CONDITIONAL.

So that

          while ((next = strchr(cp, '/'))) {

is the crazy rantings of a misguided compiler. No sane human should
ever care about some odd double parenthesis syntax. We're not writing
LISP, for chrissake.

The proper way to write this is

          while ((next = strchr(cp, '/')) != NULL) {

which makes sense to not just a machine, but to a human, and avoids
the whole "assignment used as a conditional" warning very naturally.

See? Now it uses a conditional as a conditional. Doesn't that make a
whole lot more sense than the crazy ramblings of a broken machine
mind?

I fixed it up manually, I just wanted to rant against this kind of
"mindlessly take advice from the compiler without thinking about it".

                   Linus



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux