Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1501788imc; Mon, 11 Mar 2019 15:32:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4R+RcwfqN53W6JFqkWhCxqxy4WbrejLZEQ9WoQI1ISUST8CrOt69Vtpn5eeX+oyZKBaYx X-Received: by 2002:a17:902:2a29:: with SMTP id i38mr36330220plb.110.1552343565259; Mon, 11 Mar 2019 15:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552343565; cv=none; d=google.com; s=arc-20160816; b=F5n/RsMUEC4p4vDJlFJBXAwJMieYEOI+qkJ4Vic63LqIIKG/I6+gE1KFaXhw7VCUe7 Lzw5c0THL1TmRNr2Fx3Vt42Zv+udtD9LAdvXikC1BYARtu8fPzqcB92zrp/3oB/jSxPA VaSmyiacdUAMHB3f7/wBqbgUeSoSoWVK5Os+hK8IpOLRPpLgYlEMdAoLW71H8Hjsjr11 y4LFiqyw62k+BQigthlbWfWFcICqJ86GUnSSEPvbEXNizdmz6kAy225+EkyavjTbTRgn csg3L/0VD1DI8yDB/DYff83i8dBrD1R+AoAsINWbFdpT72ZzVnEWv6+T89rJ/lT+3yIK 73Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=Efs4/gus5mxN2GXEFSqEGS6KAi+B6W4F7J0neOpjlnY=; b=SnhzXyXC3uSZUev0YE69iuk6rX2azczBGLpkKPSQITy4Fl+VNHZ3eR9lrJaRgj9LP+ TQmFSw5Ri2mr2BbWYam5cWtWlnBRkUSfdRT5s2dgLbFosFLiYGsj2rYMRY7dotMyYAaw 6IsFnyYw+H0+tGqEt4QD1HR2FH2OjEaXTW2uFAV7Lnctr4pBoZpFUa3YsO2AkB8XH2oh +6guxritk+7sIquCHk+ZxT+nBXPUB52n3rQJgm/HMkCvgZNYL+Z7rKV3YVb1zIQ+V06l +4b1KnODTfVglpeOecKur4NPRS8piwecjbelGFgo22FQ4jiqKkYwq6PYNoJPHvheBAHh 3Ixg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p18si6330723plq.130.2019.03.11.15.32.29; Mon, 11 Mar 2019 15:32:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726418AbfCKWb4 (ORCPT + 99 others); Mon, 11 Mar 2019 18:31:56 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:45922 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726016AbfCKWbz (ORCPT ); Mon, 11 Mar 2019 18:31:55 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id D995329B43; Mon, 11 Mar 2019 18:31:50 -0400 (EDT) Date: Tue, 12 Mar 2019 09:31:50 +1100 (AEDT) From: Finn Thain To: Geert Uytterhoeven cc: Andreas Schwab , kbuild test robot , kbuild-all@01.org, linux-m68k , Arnd Bergmann , Linux Kernel Mailing List Subject: Re: [m68k:master 1174/1174] arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming offset 8 is out of the bounds [0, 7] In-Reply-To: Message-ID: References: <201903042049.npxcZzps%fengguang.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Mar 2019, Geert Uytterhoeven wrote: > On Mon, Mar 11, 2019 at 11:13 AM Andreas Schwab wrote: > > On M?r 11 2019, Geert Uytterhoeven wrote: > > > On Mon, Mar 11, 2019 at 10:56 AM Andreas Schwab wrote: > > >> On M?r 11 2019, Geert Uytterhoeven wrote: > > >> > On Thu, Mar 7, 2019 at 10:42 PM Finn Thain wrote: > > >> >> No, the link fails because the compiler still emits some references to > > >> >> strlen(). > > >> > > > >> > Despite -ffreestanding?!? > > >> > > >> *Because* of -ffreestanding. Without that, strlen would be recognized > > >> and turned into __builtin_strlen. > > > > > > Now I'm confused: if we have a static inline or #define for strlen(), > > > > Do you? > > I don't, but Finn's patch has, IINM. > You're mixing up two separate patches there. One uses a #define and the other uses a forced inline function. We were discussing the former patch when I answered your question about __HAVE_ARCH_STRLEN (which got snipped). m68k doesn't define __HAVE_ARCH_STRLEN and relies on the strlen() implementation in lib/string.c. The former patch doesn't alter this but reduces the number of callers because some call sites get optimized away. That's how it avoids the warning you raised. Anyway, I don't like pre-processor kludges. So I did another experiment with the latter (forced inline) approach, to see if some optimizations can still be used with -ffreestanding. diff --git a/include/linux/string.h b/include/linux/string.h index 7927b875f80c..25b5bf689018 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -436,6 +436,58 @@ __FORTIFY_INLINE char *strcpy(char *p, const char *q) return p; } +#else + +//__FORTIFY_INLINE char *strncpy(char *p, const char *q, __kernel_size_t size) +//{ +// return __builtin_strncpy(p, q, size); +//} + +__FORTIFY_INLINE char *strcat(char *p, const char *q) +{ + return __builtin_strcat(p, q); +} + +__FORTIFY_INLINE __kernel_size_t strlen(const char *p) +{ + return __builtin_strlen(p); +} + +__FORTIFY_INLINE char *strncat(char *p, const char *q, __kernel_size_t count) +{ + return __builtin_strncat(p, q, count); +} + +__FORTIFY_INLINE void *memset(void *p, int c, __kernel_size_t size) +{ + return __builtin_memset(p, c, size); +} + +//__FORTIFY_INLINE void *memcpy(void *p, const void *q, __kernel_size_t size) +//{ +// return __builtin_memcpy(p, q, size); +//} + +__FORTIFY_INLINE void *memmove(void *p, const void *q, __kernel_size_t size) +{ + return __builtin_memmove(p, q, size); +} + +__FORTIFY_INLINE int memcmp(const void *p, const void *q, __kernel_size_t size) +{ + return __builtin_memcmp(p, q, size); +} + +__FORTIFY_INLINE void *memchr(const void *p, int c, __kernel_size_t size) +{ + return __builtin_memchr(p, c, size); +} + +__FORTIFY_INLINE char *strcpy(char *p, const char *q) +{ + return __builtin_strcpy(p, q); +} + #endif /** The result of this patch really is confusing. It still suppresses the warning you raised: arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming offset 8 is out of the bounds [0, 7] [-Warray-bounds] #define memcpy(d, s, n) __builtin_memcpy(d, s, n) ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/string.h:456:3: note: in expansion of macro 'memcpy' memcpy(dest, src, dest_len); ^~~~~~ But it also causes new ones, because of __builtin_memset(): drivers/video/fbdev/core/fbcvt.c: In function 'fb_find_mode_cvt': drivers/video/fbdev/core/fbcvt.c:312:16: warning: 'cvt.flags' may be used uninit ialized in this function [-Wmaybe-uninitialized] cvt.flags |= FB_CVT_FLAG_MARGINS; ^~ Apparently the compiler doesn't understand that __builtin_memset() has the effect of initialization. Weird. -- > Gr{oetje,eeting}s, > > Geert > >