Files
linux-cryptodev-2.6/include/linux
Vincent Mailhol 243c90e917 build_bug.h: more user friendly error messages in BUILD_BUG_ON_ZERO()
__BUILD_BUG_ON_ZERO_MSG(), as introduced in [1], makes it possible to
do a static assertions in expressions. The direct benefit is to
provide a meaningful error message instead of the cryptic negative
bitfield size error message currently returned by BUILD_BUG_ON_ZERO():

  ./include/linux/build_bug.h:16:51: error: negative width in bit-field '<anonymous>'
     16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
        |                                                   ^

Get rid of BUILD_BUG_ON_ZERO()'s bitfield size hack. Instead rely on
__BUILD_BUG_ON_ZERO_MSG() which in turn relies on C11's
_Static_assert().

Use some macro magic, similarly to static_assert(), to either use an
optional error message provided by the user or, when omitted, to
produce a default error message by stringifying the tested
expression. With this, for example:

  BUILD_BUG_ON_ZERO(1 > 0)

would now throw:

  ./include/linux/compiler.h:197:62: error: static assertion failed: "1 > 0 is true"
    197 | define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
        |                                                             ^~~~~~~~~~~~~~

Finally, __BUILD_BUG_ON_ZERO_MSG() is already guarded by an:

  #ifdef __CHECKER__

So no need any more for that guard clause for BUILD_BUG_ON_ZERO().
Remove it.

[1] commit d7a516c6ee ("compiler.h: Fix undefined BUILD_BUG_ON_ZERO()")
Link: https://git.kernel.org/torvalds/c/d7a516c6eeae

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://git.kernel.org/next/linux-next/c/b88937277df
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
2025-04-29 15:58:38 -04:00
..
2025-04-03 21:35:32 +02:00
2025-03-21 09:46:08 +01:00
2025-03-21 20:57:55 -03:00
2025-03-13 14:15:54 +00:00
2025-02-21 17:31:45 -06:00
2025-02-21 09:54:01 +01:00
2025-04-29 15:58:38 -04:00
2025-04-02 07:06:59 -06:00
2025-03-08 14:37:39 +01:00
2025-02-26 12:10:48 +01:00
2025-02-06 11:27:16 -07:00
2025-04-29 15:58:38 -04:00
2025-03-17 22:06:41 -07:00
2025-02-24 12:08:51 +02:00
2025-01-07 18:06:51 -08:00
2025-03-10 13:13:04 -07:00
2025-03-22 15:36:49 +02:00
2025-01-14 19:45:35 +01:00
2025-03-08 12:13:25 +01:00
2025-02-20 15:24:13 +01:00
2025-02-07 23:15:01 +05:30
2025-02-07 16:53:04 +01:00
2025-01-15 15:07:23 -08:00
2025-04-15 11:32:34 +02:00
2025-03-17 13:54:50 +00:00
2025-04-29 15:58:37 -04:00
2025-02-18 11:51:22 -05:00
2025-03-06 15:13:13 -04:00
2025-03-27 13:14:46 -05:00
2025-03-08 15:08:45 -06:00
2025-03-10 08:53:40 +01:00
2025-03-12 20:41:14 +01:00
2025-01-10 11:59:00 +01:00
2025-01-07 15:16:48 +01:00
2025-03-16 17:40:22 -07:00
2025-01-02 10:37:14 -06:00
2025-03-17 11:52:25 +01:00
2025-01-29 13:32:23 -08:00
2025-01-29 09:04:28 -08:00
2025-02-28 11:51:26 -08:00
2025-03-20 08:00:50 -07:00
2025-02-28 11:51:26 -08:00
2025-03-25 09:15:07 -07:00
2025-02-12 12:12:27 +01:00
2025-02-28 11:51:26 -08:00
2025-04-18 10:05:49 -04:00
2025-03-13 13:25:58 -07:00
2025-03-13 13:25:58 -07:00
2025-03-13 13:25:58 -07:00