From: Finn Thain <fthain@telegraphics.com.au>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
kbuild test robot <lkp@intel.com>,
kbuild-all@01.org, linux-m68k <linux-m68k@lists.linux-m68k.org>,
Arnd Bergmann <arnd@arndb.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
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]
Date: Tue, 12 Mar 2019 09:31:50 +1100 (AEDT) [thread overview]
Message-ID: <alpine.LNX.2.21.1903120856310.282@nippy.intranet> (raw)
In-Reply-To: <CAMuHMdXztDOGWDSKyOuaQzK9WxWoDPz-AJFRVyF7PyRiM68ugg@mail.gmail.com>
On Mon, 11 Mar 2019, Geert Uytterhoeven wrote:
> On Mon, Mar 11, 2019 at 11:13 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
> > On M?r 11 2019, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > On Mon, Mar 11, 2019 at 10:56 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
> > >> On M?r 11 2019, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > >> > On Thu, Mar 7, 2019 at 10:42 PM Finn Thain <fthain@telegraphics.com.au> 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
>
>
next prev parent reply other threads:[~2019-03-11 22:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <201903042049.npxcZzps%fengguang.wu@intel.com>
2019-03-04 13:05 ` Geert Uytterhoeven
2019-03-05 2:56 ` Finn Thain
2019-03-05 2:59 ` Finn Thain
2019-03-05 7:49 ` Geert Uytterhoeven
2019-03-05 8:58 ` Finn Thain
2019-03-05 9:03 ` Geert Uytterhoeven
2019-03-05 9:04 ` Andreas Schwab
2019-03-07 2:59 ` Finn Thain
2019-03-07 8:30 ` Geert Uytterhoeven
2019-03-07 21:43 ` Finn Thain
2019-03-11 9:14 ` Geert Uytterhoeven
2019-03-11 9:56 ` Andreas Schwab
2019-03-11 10:05 ` Geert Uytterhoeven
2019-03-11 10:13 ` Andreas Schwab
2019-03-11 10:20 ` Geert Uytterhoeven
2019-03-11 22:31 ` Finn Thain [this message]
2019-03-18 2:53 ` Finn Thain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.21.1903120856310.282@nippy.intranet \
--to=fthain@telegraphics.com.au \
--cc=arnd@arndb.de \
--cc=geert@linux-m68k.org \
--cc=kbuild-all@01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=lkp@intel.com \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®