This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Avoid array-bounds warning in testsuite on i586


Florian Weimer <fweimer@redhat.com> writes:

> Or we could cast to uintptr_t before subtracting 1.

That works.

Andreas.

Subject: [PATCH] Avoid array-bounds warning for strncat on i586

	[BZ #20260]
	* sysdeps/x86/bits/string.h (__strncat_g) [!__i686__]: Compute the
	address before the beginning of the string as an integer to avoid
	array-bounds warning.
---
 sysdeps/x86/bits/string.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 8dfce05..805d33f 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -1089,7 +1089,6 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
      :  "g" (__n), "0" (0), "1" (__tmp), "2" (__src), "3" (0xffffffff)
      : "memory", "cc");
 # else
-  --__tmp;
   __asm__ __volatile__
     ("1:\n\t"
      "cmpb	$0,1(%1)\n\t"
@@ -1108,7 +1107,7 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
      "3:\n\t"
      "movb	$0,(%1)"
      : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), "=&r" (__n)
-     : "1" (__tmp), "2" (__src), "3" (__n)
+     : "1" ((unsigned long) __tmp - 1), "2" (__src), "3" (__n)
      : "memory", "cc");
 #endif
   return __dest;
-- 
2.9.0


-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]