linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: akpm@linux-foundation.org,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] linux/container_of.h: switch to static_assert
Date: Fri, 15 Oct 2021 16:11:01 +0300	[thread overview]
Message-ID: <YWl95fZ69qpECxqi@smile.fi.intel.com> (raw)
In-Reply-To: <20211015090530.2774079-1-linux@rasmusvillemoes.dk>

On Fri, Oct 15, 2021 at 11:05:30AM +0200, Rasmus Villemoes wrote:
> _Static_assert() is evaluated already in the compiler's frontend, and
> gives a somehat more to-the-point error, compared to the BUILD_BUG_ON
> macro, which only fires after the optimizer has had a chance to
> eliminate calls to functions marked with
> __attribute__((error)). In theory, this might make builds a tiny bit
> faster.
> 
> There's also a little less gunk in the error message emitted:
> 
> lib/sort.c: In function ‘foo’:
> ./include/linux/build_bug.h:78:41: error: static assertion failed: "pointer type mismatch in container_of()"
>    78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> 
> compared to
> 
> lib/sort.c: In function ‘foo’:
> ././include/linux/compiler_types.h:322:38: error: call to ‘__compiletime_assert_2’ declared with attribute error: pointer type mismatch in container_of()
>   322 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> 
> While at it, fix the copy-pasto in container_of_safe().

Thanks, Rasmus!
Make sense to me.
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> akpm: This is obviously on top of Andy's kernel.h splitup series, so
> should go along with those if acked.

Nevertheless, kbuild bot is not happy about bottom_half.h (_RET_IP_, _THIS_IP_
definitions). Do you have any idea what to do the best? (I think those macros
deserve a separate header as well).

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2021-10-15 10:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15  9:05 [PATCH] linux/container_of.h: switch to static_assert Rasmus Villemoes
2021-10-15 13:08 ` Miguel Ojeda
2021-10-15 13:11 ` Andy Shevchenko [this message]
2021-10-15 13:13   ` Andy Shevchenko
2021-10-15 11:46     ` Rasmus Villemoes
2021-10-15 17:33 ` Nick Desaulniers

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=YWl95fZ69qpECxqi@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ndesaulniers@google.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).