linker: simplify how warnings turn into errors past a certain api level.
This was motivated by the fact that most of the _anchors_ on the doc page were outdated. I've taken the simple expedient of removing those. I was then struck by the amount of copy & paste involved in showing both warning and error, so the new function takes care of that.
Change-Id: I82d3e6a6d8235a78f7cfe427b1209a1f9c83f682
diff --git a/linker/linker_globals.cpp b/linker/linker_globals.cpp
index 4a17d09..c3a3bcd 100644
--- a/linker/linker_globals.cpp
+++ b/linker/linker_globals.cpp
@@ -52,19 +52,24 @@
return sizeof(__linker_dl_err_buf);
}
-void DL_WARN_documented_change(int api_level, const char* doc_fragment, const char* fmt, ...) {
- std::string result{"Warning: "};
-
+bool DL_ERROR_AFTER(int target_sdk_version, const char* fmt, ...) {
+ std::string result;
va_list ap;
va_start(ap, fmt);
android::base::StringAppendV(&result, fmt, ap);
va_end(ap);
- android::base::StringAppendF(&result,
- " and will not work when the app moves to API level %d or later "
- "(%s#%s) (allowing for now because this app's target API level is "
- "still %d)",
- api_level, kBionicChangesUrl, doc_fragment,
- get_application_target_sdk_version());
- DL_WARN("%s", result.c_str());
+ if (get_application_target_sdk_version() < target_sdk_version) {
+ android::base::StringAppendF(&result,
+ " and will not work when the app moves to API level %d or later "
+ "(see https://android.googlesource.com/platform/bionic/+/main/"
+ "android-changes-for-ndk-developers.md); "
+ "allowing for now because this app's target API level is still %d",
+ target_sdk_version,
+ get_application_target_sdk_version());
+ DL_WARN("Warning: %s", result.c_str());
+ return false;
+ }
+ DL_ERR_AND_LOG("%s", result.c_str());
+ return true;
}