Merge "__system_property_set: add string names for init's error codes." into main am: 899d809bca

Original change: https://android-review.googlesource.com/c/platform/bionic/+/3053422

Change-Id: I6e99edb16376c117a5b3ab49fabf2fb5a7aaa545
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Elliott Hughes 2024-04-22 22:34:17 +00:00 committed by Automerger Merge Worker
commit 52475d9249

View file

@ -257,6 +257,21 @@ static void detect_protocol_version() {
}
}
static const char* __prop_error_to_string(int error) {
switch (error) {
case PROP_ERROR_READ_CMD: return "PROP_ERROR_READ_CMD";
case PROP_ERROR_READ_DATA: return "PROP_ERROR_READ_DATA";
case PROP_ERROR_READ_ONLY_PROPERTY: return "PROP_ERROR_READ_ONLY_PROPERTY";
case PROP_ERROR_INVALID_NAME: return "PROP_ERROR_INVALID_NAME";
case PROP_ERROR_INVALID_VALUE: return "PROP_ERROR_INVALID_VALUE";
case PROP_ERROR_PERMISSION_DENIED: return "PROP_ERROR_PERMISSION_DENIED";
case PROP_ERROR_INVALID_CMD: return "PROP_ERROR_INVALID_CMD";
case PROP_ERROR_HANDLE_CONTROL_MESSAGE: return "PROP_ERROR_HANDLE_CONTROL_MESSAGE";
case PROP_ERROR_SET_FAILED: return "PROP_ERROR_SET_FAILED";
}
return "<unknown>";
}
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
int __system_property_set(const char* key, const char* value) {
if (key == nullptr) return -1;
@ -310,8 +325,8 @@ int __system_property_set(const char* key, const char* value) {
if (result != PROP_SUCCESS) {
async_safe_format_log(ANDROID_LOG_WARN, "libc",
"Unable to set property \"%s\" to \"%s\": error code: 0x%x", key, value,
result);
"Unable to set property \"%s\" to \"%s\": %s (0x%x)", key, value,
__prop_error_to_string(result), result);
return -1;
}