Skip to content

Commit

Permalink
xtensa: shut up gcc-8 warnings
Browse files Browse the repository at this point in the history
Many uses of strncpy() on xtensa causes  a warning like

arch/xtensa/include/asm/string.h:56:42: warning: array subscript is above array bounds [-Warray-bounds]
   : "0" (__dest), "1" (__src), "r" (__src+__n)

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>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  • Loading branch information
Arnd Bergmann authored and Max Filippov committed Jan 2, 2018
1 parent fed566c commit 32bb954
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/xtensa/include/asm/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static inline char *strncpy(char *__dest, const char *__src, size_t __n)
"bne %1, %5, 1b\n"
"2:"
: "=r" (__dest), "=r" (__src), "=&r" (__dummy)
: "0" (__dest), "1" (__src), "r" (__src+__n)
: "0" (__dest), "1" (__src), "r" ((uintptr_t)__src+__n)
: "memory");

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

return __res;
}
Expand Down

0 comments on commit 32bb954

Please sign in to comment.