Re: [PATCH] Enable '-Werror' by default for all kernel builds
From: Guenter Roeck
Date: Wed Sep 08 2021 - 09:54:17 EST
On 9/8/21 6:19 AM, Al Viro wrote:
On Wed, Sep 08, 2021 at 05:42:30AM -0700, Guenter Roeck wrote:
Oddly enough, a memcpy on the 'rtc' variable doesn't fail,
neither with nor without volatile. Something else is going on.
While we are at it, would memcpy_fromio() complain? Seeing that
this is what's really intended there...
It doesn't make a difference on m68k.
#define memcpy_fromio memcpy_fromio
static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,
int count)
{
__builtin_memcpy(dst, (void __force *) src, count);
}
It boils down to the use of __builtin_memcpy(). m68k implements its own version
of memcpy(). If that is used, everything works fine. However, if a file includes
<linux/string.h>, memcpy is replaced with __builtin_memcpy:
#define __HAVE_ARCH_MEMCPY
extern void *memcpy(void *, const void *, __kernel_size_t);
#define memcpy(d, s, n) __builtin_memcpy(d, s, n)
and the compilation fails.
That also explains why only some architectures/files are affected.
Presumably those are the architectures which use __builtin_memcpy().
Guenter