From: Joe Perches <joe@perches.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "David Miller" <davem@davemloft.net>,
ast@plumgrid.com, dborkman@redhat.com,
"Ingo Molnar" <mingo@kernel.org>,
"Will Drewry" <wad@chromium.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Peter Zijlstra" <a.p.zijlstra@chello.nl>,
"Peter Anvin" <hpa@zytor.com>,
"Hagen Paul Pfeifer" <hagen@jauu.net>,
"Jesse Gross" <jesse@nicira.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Eric Dumazet" <edumazet@google.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"Arnaldo Carvalho de Melo" <acme@infradead.org>,
penberg@iki.fi, "Arjan van de Ven" <arjan@infradead.org>,
"Christoph Hellwig" <hch@infradead.org>,
"Pavel Emelyanov" <xemul@parallels.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Network Development" <netdev@vger.kernel.org>
Subject: Re: [PATCH v8 net-next 1/3] filter: add Extended BPF interpreter and converter
Date: Mon, 10 Mar 2014 20:02:16 -0700 [thread overview]
Message-ID: <1394506936.21085.38.camel@joe-AO722> (raw)
In-Reply-To: <CA+55aFx7rdm9DGOTTgAKTHNkdfrvQYhT9PRs5MhUPr1gQzWEgA@mail.gmail.com>
On Mon, 2014-03-10 at 19:02 -0700, Linus Torvalds wrote:
> On Mon, Mar 10, 2014 at 6:51 PM, David Miller <davem@davemloft.net> wrote:
> > From: Alexei Starovoitov <ast@plumgrid.com>
> > Date: Sun, 9 Mar 2014 23:04:02 -0700
> >
> >> + unsigned int jited:1;
> >
> > The C language has a proper type for boolean states, please therefore
> > use 'bool', true, and false.
>
> No, the C standard actually has no such thing.
>
> In a structure, a bitfield is actually better than bool, because it
> takes only one bit. A "bool" takes at least a byte.
Bitfields can also be _Bool and at least for gcc
_Bool bitfields are required to be :1.
> Now, in this case it may not be an issue (looks like there are no
> other uses that can use the better packing, so bit/byte/word is all
> the same), but I really really want to make it clear that it is not at
> all true that "bool" is somehow better than a single-bit bitfield. The
> bitfield can pack *much* better, and I would actually say that it's
> generally a *better* idea to use a bitfield, because you can much more
> easily expand on it later by adding other bitfields.
bitfields generate relatively poor code and are frequently
disadvantageous due to read-modify-write requirements.
> There are very few actual real advantages to "bool". The magic casting
> behavior is arguably an advantage (the implicit cast in assigning to a
> bitfield truncates to the low bits, the implicit cast on assignment to
> "bool" does a test against zero), but is also quite arguably a
> possible source of confusion
Umm. Types are good.
> and can cause problems down the line when
> converting from bool to a bitfield (for the afore-mentioned packing
> reasons).
I don't see how.
> I would generally suggest that people only use "bool" for function
> return types, and absolutely nothing else. Seriously.
I think using bool for function arguments, structure members and
variables is good and frequently to mostly is an overall improvement.
next prev parent reply other threads:[~2014-03-11 3:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-10 6:04 [PATCH v8 net-next 0/3] filter: add Extended BPF interpreter and converter, seccomp Alexei Starovoitov
2014-03-10 6:04 ` [PATCH v8 net-next 1/3] filter: add Extended BPF interpreter and converter Alexei Starovoitov
2014-03-11 1:51 ` David Miller
2014-03-11 2:02 ` Linus Torvalds
2014-03-11 2:05 ` Linus Torvalds
2014-03-11 2:20 ` H. Peter Anvin
2014-03-11 2:57 ` Alexei Starovoitov
2014-03-11 2:24 ` David Miller
2014-03-11 2:33 ` H. Peter Anvin
2014-03-11 2:39 ` David Miller
2014-03-11 3:05 ` Linus Torvalds
2014-03-11 9:51 ` David Laight
2014-03-11 3:02 ` Joe Perches [this message]
2014-03-10 6:04 ` [PATCH v8 net-next 2/3] seccomp: convert seccomp to use extended BPF Alexei Starovoitov
2014-03-10 6:04 ` [PATCH v8 net-next 3/3] doc: filter: add Extended BPF documentation Alexei Starovoitov
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=1394506936.21085.38.camel@joe-AO722 \
--to=joe@perches.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=hagen@jauu.net \
--cc=hch@infradead.org \
--cc=hpa@zytor.com \
--cc=jesse@nicira.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=penberg@iki.fi \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=wad@chromium.org \
--cc=xemul@parallels.com \
/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