Revert "fortify: allow diagnostics without run-time checks"

This reverts commit d7e11b88531665de59de466bbc9ee6c480b00a4f.

Reason for revert: Breaks aosp_x86_64-eng. Will look into it and
unbreak when it's not almost midnight. :)

Change-Id: I21f76efe4d19c70d0b14630e441376d359a45b49
diff --git a/libc/include/bits/fortify/string.h b/libc/include/bits/fortify/string.h
index 3bfbfe9..bd36483 100644
--- a/libc/include/bits/fortify/string.h
+++ b/libc/include/bits/fortify/string.h
@@ -40,7 +40,7 @@
 #if defined(__BIONIC_FORTIFY)
 extern void* __memrchr_real(const void*, int, size_t) __RENAME(memrchr);
 
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
 /* No diag -- clang diagnoses misuses of this on its own.  */
 __BIONIC_FORTIFY_INLINE
 void* memcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount)
@@ -61,7 +61,7 @@
     }
     return __builtin___memmove_chk(dst, src, len, bos_dst);
 }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
 
 #if defined(__USE_GNU)
 #if __ANDROID_API__ >= __ANDROID_API_R__
@@ -70,13 +70,11 @@
         __overloadable
         __clang_error_if(__bos_unevaluated_lt(__bos0(dst), copy_amount),
                          "'mempcpy' called with size bigger than buffer") {
-#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
     size_t bos_dst = __bos0(dst);
-    if (!__bos_trivially_ge(bos_dst, copy_amount)) {
-        return __builtin___mempcpy_chk(dst, src, copy_amount, bos_dst);
+    if (__bos_trivially_ge(bos_dst, copy_amount)) {
+        return __builtin_mempcpy(dst, src, copy_amount);
     }
-#endif
-    return __builtin_mempcpy(dst, src, copy_amount);
+    return __builtin___mempcpy_chk(dst, src, copy_amount, bos_dst);
 }
 #endif /* __ANDROID_API__ >= __ANDROID_API_R__ */
 #endif /* __USE_GNU */
@@ -86,12 +84,12 @@
         __overloadable
         __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)),
                          "'stpcpy' called with string bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_L__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_L__
     size_t bos_dst = __bos(dst);
     if (!__bos_trivially_gt(bos_dst, __builtin_strlen(src))) {
         return __builtin___stpcpy_chk(dst, src, bos_dst);
     }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
     return __builtin_stpcpy(dst, src);
 }
 
@@ -100,12 +98,12 @@
         __overloadable
         __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)),
                          "'strcpy' called with string bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
     size_t bos_dst = __bos(dst);
     if (!__bos_trivially_gt(bos_dst, __builtin_strlen(src))) {
         return __builtin___strcpy_chk(dst, src, bos_dst);
     }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
     return __builtin_strcpy(dst, src);
 }
 
@@ -114,36 +112,36 @@
         __overloadable
         __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)),
                          "'strcat' called with string bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
     return __builtin___strcat_chk(dst, src, __bos(dst));
 #else
     return __builtin_strcat(dst, src);
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
 }
 
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
 /* No diag -- clang diagnoses misuses of this on its own.  */
 __BIONIC_FORTIFY_INLINE
 char* strncat(char* const dst __pass_object_size, const char* src, size_t n) __overloadable {
     return __builtin___strncat_chk(dst, src, n, __bos(dst));
 }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
 
 /* No diag -- clang diagnoses misuses of this on its own.  */
 __BIONIC_FORTIFY_INLINE
 void* memset(void* const s __pass_object_size0, int c, size_t n) __overloadable
         /* If you're a user who wants this warning to go away: use `(&memset)(foo, bar, baz)`. */
         __clang_warning_if(c && !n, "'memset' will set 0 bytes; maybe the arguments got flipped?") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
     size_t bos = __bos0(s);
     if (!__bos_trivially_ge(bos, n)) {
         return __builtin___memset_chk(s, c, n, bos);
     }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
     return __builtin_memset(s, c, n);
 }
 
-#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_M__
 __BIONIC_FORTIFY_INLINE
 void* memchr(const void* const s __pass_object_size, int c, size_t n) __overloadable {
     size_t bos = __bos(s);
@@ -165,9 +163,9 @@
 
     return __memrchr_chk(s, c, n, bos);
 }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
 
-#if __ANDROID_API__ >= __ANDROID_API_L__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_L__
 /* No diag -- clang diagnoses misuses of this on its own.  */
 __BIONIC_FORTIFY_INLINE
 char* stpncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n)
@@ -197,20 +195,20 @@
 
     return __strncpy_chk2(dst, src, n, bos_dst, bos_src);
 }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
 
 __BIONIC_FORTIFY_INLINE
 size_t strlcpy(char* const dst __pass_object_size, const char* src, size_t size)
         __overloadable
         __clang_error_if(__bos_unevaluated_lt(__bos(dst), size),
                          "'strlcpy' called with size bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
     size_t bos = __bos(dst);
 
     if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) {
         return __strlcpy_chk(dst, src, size, bos);
     }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
     return __call_bypassing_fortify(strlcpy)(dst, src, size);
 }
 
@@ -219,13 +217,13 @@
         __overloadable
         __clang_error_if(__bos_unevaluated_lt(__bos(dst), size),
                          "'strlcat' called with size bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
     size_t bos = __bos(dst);
 
     if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) {
         return __strlcat_chk(dst, src, size, bos);
     }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
     return __call_bypassing_fortify(strlcat)(dst, src, size);
 }
 
@@ -233,39 +231,39 @@
 size_t strlen(const char* const s __pass_object_size0) __overloadable {
     size_t bos = __bos0(s);
 
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
     if (!__bos_trivially_gt(bos, __builtin_strlen(s))) {
         return __strlen_chk(s, bos);
     }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
     return __builtin_strlen(s);
 }
 
 __BIONIC_FORTIFY_INLINE
 char* strchr(const char* const s __pass_object_size, int c) __overloadable {
-#if  __ANDROID_API__ >= __ANDROID_API_J_MR2__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if  __ANDROID_API__ >= __ANDROID_API_J_MR2__
     size_t bos = __bos(s);
 
     if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) {
         return __strchr_chk(s, c, bos);
     }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */
     return __builtin_strchr(s, c);
 }
 
 __BIONIC_FORTIFY_INLINE
 char* strrchr(const char* const s __pass_object_size, int c) __overloadable {
-#if  __ANDROID_API__ >= __ANDROID_API_J_MR2__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if  __ANDROID_API__ >= __ANDROID_API_J_MR2__
     size_t bos = __bos(s);
 
     if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) {
         return __strrchr_chk(s, c, bos);
     }
-#endif
+#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */
     return __builtin_strrchr(s, c);
 }
 
-#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
+#if __ANDROID_API__ >= __ANDROID_API_M__
 #if defined(__cplusplus)
 extern "C++" {
 __BIONIC_FORTIFY_INLINE