linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: Thomas Gleixner <tglx@linutronix.de>, Jiri Slaby <jslaby@suse.cz>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"the arch/x86 maintainers" <x86@kernel.org>
Subject: Re: [GIT pull] core/urgent for v5.4-rc7
Date: Mon, 11 Nov 2019 09:12:13 -0800	[thread overview]
Message-ID: <CAHk-=wgmeR6nJqYFZAUOxBkUTfySE_dEV7HOB0wwzQ0e-_y4dA@mail.gmail.com> (raw)
In-Reply-To: <56f05dfb50dfc506a9cab539e522e8f80c738a4b.camel@perches.com>

On Sun, Nov 10, 2019 at 5:50 PM Joe Perches <joe@perches.com> wrote:
>
> The !! logical usage is not particularly common in the kernel.
> There seems to be only a couple/few dozen.

Your grep pattern is for the explicitly silly "turn a boolean to a
boolean". That should certainly be rare.

But I meant it in a more general way - there's a lot of common use of
"!!" for "turn this expression into a boolean". A trivial grep for
that (didn't check how correct it was - there might be comments that
are very excited too) implies that we have a fair amount of this
pattern:

    $ git grep '[^!]!![^!]' -- '*.[ch]' | wc -l
    7007

so the '!!' pattern itself isn't rare.

It's so common that the fact that people then occasionally get
confused and over-use it a bit in contexts where it's already boolean
isn't so surprising.

Personally, I still find that pattern non-intuitive, even when used
correctly. Double negatives aren't considered good in English, I don't
find it all that natural in C either.

But it's a pattern, it's idiomatic, and it's certainly not worth
forcing my own personal quirk on other people, so I won't accept
scripted patches to change it.

The one pattern I _really_ hate is the thing that some people are
taught to do: using "5 == x" instead of "x == 5" because it really
reads completely bogusly to me. Some people are taught that pattern
because it minimizes the risk of confusion between "==" and "=", and I
think that's completely wrong-headed.

Trying to teach people to write illegible code just to catch a syntax
error is crazy. You're "fixing" the wrong thing.

Oh well. We have a couple of those in the kernel too.  And I'm not
going to enforce my personal quirks there either, even if I'm
ClearlyRight(tm) and hold the OnlyCorrectOpinion(tm) in this matter.

                   Linus

  reply	other threads:[~2019-11-11 17:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-10 10:21 [GIT pull] core/urgent for v5.4-rc7 Thomas Gleixner
2019-11-10 10:21 ` [GIT pull] timers/urgent " Thomas Gleixner
2019-11-10 21:00   ` pr-tracker-bot
2019-11-10 10:21 ` [GIT pull] perf/urgent " Thomas Gleixner
2019-11-10 21:00   ` pr-tracker-bot
2019-11-10 10:21 ` [GIT pull] sched/urgent " Thomas Gleixner
2019-11-10 21:00   ` pr-tracker-bot
2019-11-10 10:21 ` [GIT pull] x86/urgent " Thomas Gleixner
2019-11-10 21:00   ` pr-tracker-bot
2019-11-10 10:21 ` [GIT pull] irq/urgent " Thomas Gleixner
2019-11-10 21:00   ` pr-tracker-bot
2019-11-10 21:00 ` [GIT pull] core/urgent " pr-tracker-bot
2019-11-10 22:00 ` Joe Perches
2019-11-10 22:35   ` Linus Torvalds
2019-11-11  1:50     ` Joe Perches
2019-11-11 17:12       ` Linus Torvalds [this message]
2019-11-12  1:37         ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHk-=wgmeR6nJqYFZAUOxBkUTfySE_dEV7HOB0wwzQ0e-_y4dA@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=joe@perches.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).