diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h index 19e2c46..cddefb7 100644 --- a/arch/x86/include/asm/string_64.h +++ b/arch/x86/include/asm/string_64.h @@ -52,7 +52,17 @@ extern void *__memcpy(void *to, const void *from, size_t len); #endif #define __HAVE_ARCH_MEMSET -void *memset(void *s, int c, size_t n); +extern void __warn_memset_zero_len (void) __attribute__((__warning__ ("memset used with constant zero length parameter; this could be due to transposed parameters"))); +extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) void * +__attribute__ ((__nothrow__)) memset (void *__dest, int __ch, size_t __len) +{ + if (__builtin_constant_p (__len) && __len == 0) + { + __warn_memset_zero_len (); + return __dest; + } + return __builtin___memset_chk (__dest, __ch, __len, __builtin_object_size (__dest, 0)); +} #define __HAVE_ARCH_MEMMOVE void *memmove(void *dest, const void *src, size_t count);