linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Arnd Bergmann <arnd@arndb.de>, David Laight <David.Laight@aculab.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] bitfield: avoid gcc-8 -Wint-in-bool-context warning
Date: Tue, 14 Aug 2018 13:10:28 +0200	[thread overview]
Message-ID: <1534245028.3547.16.camel@sipsolutions.net> (raw)
In-Reply-To: <CAK8P3a2-rQ2wp77dHJv9sKg+0oZrnNqMxGGJmyMWxBSfL03LKA@mail.gmail.com> (sfid-20180814_130819_139141_6879BFD8)

On Tue, 2018-08-14 at 13:08 +0200, Arnd Bergmann wrote:

> > It would be much more useful to indicate where the values are used.
> > Such a field/parameter could (probably) have the type of the enum.
> > But, at some point, the compiler might start barfing at that at well.
> 
> I think the compiler warning here only happens because one uses
> a compile-time constant expression that is not a numeric literal value
> into a boolean operator. That doesn't mean that there is something
> wrong with the enum in particular, or that enums cause a lot of
> issues elsewhere.
> 
> I would also argue that generally speaking the BUILD_BUG_ON_MSG()
> should try to either produce the specific build failure it was designed
> for, or not produce any output at all, rather than something
> that is more confusing to developers. If we want to enforce
> passing in number literals here, we should make that an explicit
> check, or otherwise allow any compile-time constant values.

I don't see why we should only be allowed to pass a number literal
(perhaps after pre-processing), rather than any constant integer value.
Clearly it needs to be a constant for all the constant-folding to work,
but nothing else is required.

> > There are also a whole load of crappy __packed in that header file.
> > There might be one or two 64bit items on 32bit boundaries but
> > that can be solved without using __packed.
> 
> Agreed, this likely causes problems on architectures without unaligned
> load/store instructions that end up doing byte accesses to the descriptor
> fields, which in turn can confuse the hardware, and can become very
> slow when they live in dma_alloc_coherent() memory. That looks
> like a completely unrelated issue though.

We know about this, but it doesn't cause issues apart from perhaps
somewhat slower access on some architectures, since all of the
structures live only in DRAM and are not usually used with coherent
memory, just sent to/from the device.

Since the devices really only ship on x86 systems, we decided to ignore
that slight performance issue (for now).

johannes

  reply	other threads:[~2018-08-14 11:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-13 22:09 [PATCH] bitfield: avoid gcc-8 -Wint-in-bool-context warning Arnd Bergmann
2018-08-13 23:57 ` Masahiro Yamada
2018-08-14  7:56   ` Johannes Berg
2018-08-14  8:43     ` Arnd Bergmann
2018-08-14  9:31     ` Masahiro Yamada
2018-08-14 10:06     ` David Laight
2018-08-14 11:08       ` Arnd Bergmann
2018-08-14 11:10         ` Johannes Berg [this message]
2018-08-14 13:09         ` David Laight
2018-08-14 23:11 ` Andrew Morton
2018-08-14 23:13   ` Andrew Morton

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=1534245028.3547.16.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=David.Laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=jakub.kicinski@netronome.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yamada.masahiro@socionext.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;
as well as URLs for NNTP newsgroup(s).