summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2020-03-09 21:32:16 +0300
committerRich Felker <dalias@aerifal.cx>2020-03-20 15:45:08 -0400
commit526df238d0d05fe4e8446720d9d0374646f82f82 (patch)
tree6d718b69eab7383b866cad83659e6c132dcb1ed2
parent72658c658b234bf24ebbc2be1863f4c6b2f2434d (diff)
downloadmusl-526df238d0d05fe4e8446720d9d0374646f82f82.tar.gz
remove redundant condition in memccpy
Commit d9bdfd164 ("fix memccpy to not access buffer past given size") correctly added a check for 'n' nonzero, but made the pre-existing test '*s==c' redundant: n!=0 implies *s==c. Remove the unnecessary check. Reported by Alexey Izbyshev.
-rw-r--r--src/string/memccpy.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/string/memccpy.c b/src/string/memccpy.c
index 00c18e2b..3b0a3700 100644
--- a/src/string/memccpy.c
+++ b/src/string/memccpy.c
@@ -29,6 +29,6 @@ void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n)
#endif
for (; n && (*d=*s)!=c; n--, s++, d++);
tail:
- if (n && *s==c) return d+1;
+ if (n) return d+1;
return 0;
}