lkml.org 
[lkml]   [2018]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] sh: shut up gcc-8 warnings
Date
Many uses of strncpy() on sh causes  a warning like

arch/sh/include/asm/string_32.h:50:42: warning: array subscript is above array bounds [-Warray-bounds]

This avoids the warning by turning the pointer arithmetic into an
integer operation that does not get checked the same way.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/sh/include/asm/string_32.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sh/include/asm/string_32.h b/arch/sh/include/asm/string_32.h
index 55f8db6bc1d7..98ddb5bbd3b8 100644
--- a/arch/sh/include/asm/string_32.h
+++ b/arch/sh/include/asm/string_32.h
@@ -47,7 +47,7 @@ static inline char *strncpy(char *__dest, const char *__src, size_t __n)
" add #1, %0\n"
"2:"
: "=r" (__dest), "=r" (__src), "=&z" (__dummy)
- : "0" (__dest), "1" (__src), "r" (__src+__n)
+ : "0" (__dest), "1" (__src), "r" ((uintptr_t)__src+__n)
: "memory", "t");

return __xdest;
@@ -105,7 +105,7 @@ static inline int strncmp(const char *__cs, const char *__ct, size_t __n)
"sub %3, %2\n"
"3:"
:"=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
- : "0" (__cs), "1" (__ct), "r" (__cs+__n)
+ : "0" (__cs), "1" (__ct), "r" ((uintptr_t)__cs+__n)
: "t");

return __res;
--
2.9.0
\
 
 \ /
  Last update: 2018-01-02 11:58    [W:0.022 / U:14.356 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site