From 9c8e64485360d08d95884bddc0958cf3a5ca9c5c Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 1 Feb 2017 14:37:58 -0800 Subject: alpha: Use saturating arithmetic in memchr --- sysdeps/alpha/memchr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sysdeps/alpha') diff --git a/sysdeps/alpha/memchr.c b/sysdeps/alpha/memchr.c index 82c42c0731..402088dc9e 100644 --- a/sysdeps/alpha/memchr.c +++ b/sysdeps/alpha/memchr.c @@ -53,7 +53,10 @@ __memchr (const void *s, int xc, size_t n) /* Align the source, and decrement the count by the number of bytes searched in the first word. */ s_align = (const word *)((word)s & -8); - n += ((word)s & 7); + { + size_t inc = n + ((word)s & 7); + n = inc | -(inc < n); + } /* Deal with misalignment in the first word for the comparison. */ mask = (1ul << ((word)s & 7)) - 1; -- cgit v1.2.3-65-gdbad