From: Mateusz Guzik <mjguzik@gmail.com>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: rework I_NEW handling to operate without fences
Date: Tue, 25 Nov 2025 04:00:47 +0100 [thread overview]
Message-ID: <CAGudoHFSFy9KDAViEU8whypxsUN5+wXAi-Po6Tc1jw-yLE5PUg@mail.gmail.com> (raw)
In-Reply-To: <CAHc6FU5aWPsv0ZfJAjLyziGjyem9SvWY2e+ZuKDhybOWS-roYQ@mail.gmail.com>
On Tue, Nov 25, 2025 at 12:04 AM Andreas Gruenbacher
<agruenba@redhat.com> wrote:
>
> On Mon, Nov 24, 2025 at 8:25 PM Mateusz Guzik <mjguzik@gmail.com> wrote:
> > On Mon, Nov 24, 2025 at 6:47 PM Andreas Gruenbacher <agruenba@redhat.com> wrote:
> > >
> > > On Sat, Oct 11, 2025 at 12:17 AM Mateusz Guzik <mjguzik@gmail.com> wrote:
> > Was that always a thing? My grep for '!!' shows plenty of hits in the
> > kernel tree and I'm pretty sure this was an established pratice.
>
> It depends on the data type. The non-not "operator" converts non-0
> values into 1. For boolean values, that conversion is implicit. For
> example,
>
> !!0x100 == 1
> (bool)0x100 == 1
>
> but
>
> (char)0x100 == 0
>
I mean it was an established practice *specifically* for bools.
Case in point from quick grep on the kernel:
/* Internal helper functions to match cpu capability type */
static bool
cpucap_late_cpu_optional(const struct arm64_cpu_capabilities *cap)
{
return !!(cap->type & ARM64_CPUCAP_OPTIONAL_FOR_LATE_CPU);
}
static bool
cpucap_late_cpu_permitted(const struct arm64_cpu_capabilities *cap)
{
return !!(cap->type & ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU);
}
static bool
cpucap_panic_on_conflict(const struct arm64_cpu_capabilities *cap)
{
return !!(cap->type & ARM64_CPUCAP_PANIC_ON_CONFLICT);
}
I suspect the practice predates bool support in the C standard and
people afterwards never found out.
next prev parent reply other threads:[~2025-11-25 3:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 22:17 [PATCH] fs: rework I_NEW handling to operate without fences Mateusz Guzik
2025-10-15 11:50 ` Mateusz Guzik
2025-10-21 12:48 ` Christian Brauner
2025-10-21 12:54 ` Mateusz Guzik
2025-10-21 12:49 ` Christian Brauner
2025-10-22 9:41 ` Jan Kara
2025-11-24 17:47 ` Andreas Gruenbacher
2025-11-24 19:25 ` Mateusz Guzik
2025-11-24 23:04 ` Andreas Gruenbacher
2025-11-25 3:00 ` Mateusz Guzik [this message]
2025-11-25 10:39 ` Andreas Gruenbacher
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=CAGudoHFSFy9KDAViEU8whypxsUN5+wXAi-Po6Tc1jw-yLE5PUg@mail.gmail.com \
--to=mjguzik@gmail.com \
--cc=agruenba@redhat.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).