Re: [PATCH 07/45] C++: Define a header with some C++ type traits for type checking

From: kbuild test robot
Date: Mon Apr 02 2018 - 03:01:44 EST


Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.16-rc7]
[cannot apply to linus/master tip/x86/core tip/locking/core v4.16 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/David-Howells/C-Convert-the-kernel-to-C/20180402-120344
config: x86_64-randconfig-x016-201813 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

Note: the linux-review/David-Howells/C-Convert-the-kernel-to-C/20180402-120344 HEAD 6389202e6d769ba42860793ff4bb839d768ced5a builds fine.
It only hurts bisectibility.

All errors (new ones prefixed by >>):

from include/linux/kernel.h:12,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from arch/x86/purgatory/purgatory.c:13:
include/asm-generic/bitops/le.h: In function 'int test_and_clear_bit_le(int, void*)':
include/asm-generic/bitops/le.h:85:55: error: invalid conversion from 'void*' to 'volatile long unsigned int*' [-fpermissive]
return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
^
In file included from include/linux/bitops.h:38:0,
from include/linux/kernel.h:12,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from arch/x86/purgatory/purgatory.c:13:
arch/x86/include/asm/bitops.h:265:29: note: initializing argument 2 of 'bool test_and_clear_bit(long int, volatile long unsigned int*)'
static __always_inline bool test_and_clear_bit(long nr, volatile unsigned long *addr)
^~~~~~~~~~~~~~~~~~
In file included from arch/x86/include/asm/bitops.h:521:0,
from include/linux/bitops.h:38,
from include/linux/kernel.h:12,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from arch/x86/purgatory/purgatory.c:13:
include/asm-generic/bitops/le.h: In function 'int __test_and_set_bit_le(int, void*)':
include/asm-generic/bitops/le.h:90:55: error: invalid conversion from 'void*' to 'volatile long unsigned int*' [-fpermissive]
return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
^
In file included from include/linux/bitops.h:38:0,
from include/linux/kernel.h:12,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from arch/x86/purgatory/purgatory.c:13:
arch/x86/include/asm/bitops.h:246:29: note: initializing argument 2 of 'bool __test_and_set_bit(long int, volatile long unsigned int*)'
static __always_inline bool __test_and_set_bit(long nr, volatile unsigned long *addr)
^~~~~~~~~~~~~~~~~~
In file included from arch/x86/include/asm/bitops.h:521:0,
from include/linux/bitops.h:38,
from include/linux/kernel.h:12,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from arch/x86/purgatory/purgatory.c:13:
include/asm-generic/bitops/le.h: In function 'int __test_and_clear_bit_le(int, void*)':
include/asm-generic/bitops/le.h:95:57: error: invalid conversion from 'void*' to 'volatile long unsigned int*' [-fpermissive]
return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
^
In file included from include/linux/bitops.h:38:0,
from include/linux/kernel.h:12,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from arch/x86/purgatory/purgatory.c:13:
arch/x86/include/asm/bitops.h:287:29: note: initializing argument 2 of 'bool __test_and_clear_bit(long int, volatile long unsigned int*)'
static __always_inline bool __test_and_clear_bit(long nr, volatile unsigned long *addr)
^~~~~~~~~~~~~~~~~~~~
In file included from include/linux/kernel.h:7:0,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from arch/x86/purgatory/purgatory.c:13:
include/linux/printk.h: At global scope:
include/linux/linkage.h:16:31: error: expected unqualified-id before string constant
#define CPP_ASMLINKAGE extern "C"
^
include/linux/linkage.h:22:20: note: in expansion of macro 'CPP_ASMLINKAGE'
#define asmlinkage CPP_ASMLINKAGE
^~~~~~~~~~~~~~
include/linux/printk.h:141:8: note: in expansion of macro 'asmlinkage'
extern asmlinkage __printf(1, 2)
^~~~~~~~~~
include/linux/linkage.h:16:31: error: expected unqualified-id before string constant
#define CPP_ASMLINKAGE extern "C"
^
include/linux/linkage.h:22:20: note: in expansion of macro 'CPP_ASMLINKAGE'
#define asmlinkage CPP_ASMLINKAGE
^~~~~~~~~~~~~~
include/linux/printk.h:282:8: note: in expansion of macro 'asmlinkage'
extern asmlinkage void dump_stack(void) __cold;
^~~~~~~~~~
In file included from include/linux/kernel.h:16:0,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from arch/x86/purgatory/purgatory.c:13:
arch/x86/purgatory/purgatory.c: In function 'int verify_sha256_digest()':
include/linux/build_bug.h:29:45: error: types may not be defined in 'sizeof' expressions
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
^
include/linux/compiler-gcc.h:66:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__is_array(a))
^~~~~~~~~~~~~~~~~
include/linux/kernel.h:72:59: note: in expansion of macro '__must_be_array'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~~~~~~~~~~~~~
arch/x86/purgatory/purgatory.c:48:32: note: in expansion of macro 'ARRAY_SIZE'
end = purgatory_sha_regions + ARRAY_SIZE(purgatory_sha_regions);
^~~~~~~~~~
>> include/linux/build_bug.h:29:58: error: negative width in bit-field 'verify_sha256_digest()::<unnamed struct>::<anonymous>'
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
^
include/linux/compiler-gcc.h:66:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__is_array(a))
^~~~~~~~~~~~~~~~~
include/linux/kernel.h:72:59: note: in expansion of macro '__must_be_array'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~~~~~~~~~~~~~
arch/x86/purgatory/purgatory.c:48:32: note: in expansion of macro 'ARRAY_SIZE'
end = purgatory_sha_regions + ARRAY_SIZE(purgatory_sha_regions);
^~~~~~~~~~
make[2]: *** [arch/x86/purgatory/purgatory.o] Error 1
make[2]: *** [arch/x86/purgatory/sha256.o] Error 1
make[2]: Target 'arch/x86/purgatory/kexec-purgatory.c' not remade because of errors.
make[1]: *** [archprepare] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [sub-make] Error 2

vim +29 include/linux/build_bug.h

bc6245e5 Ian Abbott 2017-07-10 16
bc6245e5 Ian Abbott 2017-07-10 17 /* Force a compilation error if a constant expression is not a power of 2 */
bc6245e5 Ian Abbott 2017-07-10 18 #define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \
bc6245e5 Ian Abbott 2017-07-10 19 BUILD_BUG_ON(((n) & ((n) - 1)) != 0)
bc6245e5 Ian Abbott 2017-07-10 20 #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
bc6245e5 Ian Abbott 2017-07-10 21 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
bc6245e5 Ian Abbott 2017-07-10 22
bc6245e5 Ian Abbott 2017-07-10 23 /*
bc6245e5 Ian Abbott 2017-07-10 24 * Force a compilation error if condition is true, but also produce a
bc6245e5 Ian Abbott 2017-07-10 25 * result (of value 0 and type size_t), so the expression can be used
bc6245e5 Ian Abbott 2017-07-10 26 * e.g. in a structure initializer (or where-ever else comma expressions
bc6245e5 Ian Abbott 2017-07-10 27 * aren't permitted).
bc6245e5 Ian Abbott 2017-07-10 28 */
bc6245e5 Ian Abbott 2017-07-10 @29 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
bc6245e5 Ian Abbott 2017-07-10 30

:::::: The code at line 29 was first introduced by commit
:::::: bc6245e5efd70c41eaf9334b1b5e646745cb0fb3 bug: split BUILD_BUG stuff out into <linux/build_bug.h>

:::::: TO: Ian Abbott <abbotti@xxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip