Files
kernel_google_wahoo/include/linux
Vegard Nossum 3da83779ec compiler.h: fix error in BUILD_BUG_ON() reporting
[ Upstream commit af9c5d2e3b355854ff0e4acfbfbfadcd5198a349 ]

compiletime_assert() uses __LINE__ to create a unique function name.  This
means that if you have more than one BUILD_BUG_ON() in the same source
line (which can happen if they appear e.g.  in a macro), then the error
message from the compiler might output the wrong condition.

For this source file:

	#include <linux/build_bug.h>

	#define macro() \
		BUILD_BUG_ON(1); \
		BUILD_BUG_ON(0);

	void foo()
	{
		macro();
	}

gcc would output:

./include/linux/compiler.h:350:38: error: call to `__compiletime_assert_9' declared with attribute error: BUILD_BUG_ON failed: 0
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)

However, it was not the BUILD_BUG_ON(0) that failed, so it should say 1
instead of 0. With this patch, we use __COUNTER__ instead of __LINE__, so
each BUILD_BUG_ON() gets a different function name and the correct
condition is printed:

./include/linux/compiler.h:350:38: error: call to `__compiletime_assert_0' declared with attribute error: BUILD_BUG_ON failed: 1
  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Daniel Santos <daniel.santos@pobox.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Joe Perches <joe@perches.com>
Link: http://lkml.kernel.org/r/20200331112637.25047-1-vegard.nossum@oracle.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-04-24 07:57:24 +02:00
..
2015-10-01 12:48:11 -07:00
2015-10-17 21:22:08 -07:00
2015-10-07 18:08:15 +01:00
2016-03-09 15:34:52 -08:00
2018-04-08 11:51:57 +02:00
2018-04-24 09:32:12 +02:00
2015-11-07 10:40:47 -07:00
2015-09-08 15:35:28 -07:00
2015-10-18 10:14:39 -07:00
2019-03-23 08:44:38 +01:00
2019-11-25 15:54:25 +01:00
2017-07-15 11:57:44 +02:00
2015-10-30 01:47:27 -04:00
2018-01-17 09:35:30 +01:00
2020-04-02 19:02:31 +02:00
2017-08-06 19:19:42 -07:00
2020-04-02 19:02:31 +02:00
2015-09-08 15:35:28 -07:00
2016-04-20 15:42:02 +09:00
2015-10-23 05:44:28 -07:00
2015-10-01 15:06:43 +02:00
2015-10-13 19:01:25 +02:00
2016-10-28 03:01:30 -04:00
2015-08-18 15:49:15 -07:00
2015-07-28 08:50:42 +01:00
2020-04-02 19:02:39 +02:00
2015-11-23 09:44:58 +01:00
2015-10-27 18:55:31 -07:00
2015-10-20 22:10:45 +08:00
2016-03-03 15:07:28 -08:00
2015-09-10 13:29:01 -07:00
2015-11-06 17:50:42 -08:00
2016-12-08 07:15:24 +01:00
2017-08-24 17:02:36 -07:00
2015-10-09 17:00:32 -04:00
2015-10-22 08:59:18 -07:00
2020-04-24 07:57:12 +02:00
2020-04-02 19:02:39 +02:00
2019-11-10 11:21:14 +01:00
2016-09-30 10:18:37 +02:00
2019-04-27 09:33:54 +02:00
2018-11-21 09:27:36 +01:00
2019-06-17 19:54:22 +02:00
2016-04-12 09:08:35 -07:00
2015-08-17 11:25:28 -07:00
2015-10-01 09:57:59 -07:00
2015-10-19 01:01:21 +02:00
2018-11-27 16:08:02 +01:00
2015-11-23 09:44:58 +01:00
2020-04-02 19:02:31 +02:00
2020-04-02 19:02:39 +02:00
2015-12-13 14:30:59 -08:00
2015-11-13 20:34:33 -05:00
2015-09-08 15:35:28 -07:00