]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/alpha/memchr.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / alpha / memchr.c
index 82c42c073134198deba484ddff50380e8237cac0..b26cb517978edbe0a152b76a2c473e4e95e27b69 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -13,7 +13,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #include <string.h>
 
@@ -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;