fortify: simplify strlen for LLVM's new optimization
LLVM now knows how to fold __strlen_chk, so we can make this function a
one-liner.
Also fix strlcat to not double-return while I'm in the area.
Bug: 148189733
Test: TreeHugger
Change-Id: I71ee308defbefe96f3fe6e357a2127309d2f0942
diff --git a/libc/include/bits/fortify/string.h b/libc/include/bits/fortify/string.h
index 4a7ed12..beb5ff5 100644
--- a/libc/include/bits/fortify/string.h
+++ b/libc/include/bits/fortify/string.h
@@ -204,21 +204,17 @@
"'strlcat' called with size bigger than buffer") {
#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
return __strlcat_chk(dst, src, size, __bos(dst));
-#endif
+#else
return __call_bypassing_fortify(strlcat)(dst, src, size);
+#endif
}
+#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
__BIONIC_FORTIFY_INLINE
size_t strlen(const char* const s __pass_object_size0) __overloadable {
-#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
- size_t bos = __bos0(s);
-
- if (!__bos_trivially_gt(bos, __builtin_strlen(s))) {
- return __strlen_chk(s, bos);
- }
-#endif
- return __builtin_strlen(s);
+ return __strlen_chk(s, __bos0(s));
}
+#endif
__BIONIC_FORTIFY_INLINE
char* strchr(const char* const s __pass_object_size, int c) __overloadable {