[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YWl95fZ69qpECxqi@smile.fi.intel.com>
Date: Fri, 15 Oct 2021 16:11:01 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: akpm@...ux-foundation.org,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] linux/container_of.h: switch to static_assert
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@...ux.intel.com>
> Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.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
Powered by blists - more mailing lists