diff options
author | Elliott Hughes <enh@google.com> | 2024-04-22 22:18:15 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-04-22 22:18:15 +0000 |
commit | 899d809bca0cbe61a18b376dafdfcdb578324a9e (patch) | |
tree | 303ec4aeb00434fb229ba416a4345e1a9bccd74c | |
parent | ed21ffc70a4656492fa7f67cba8fa5aa2b232b48 (diff) | |
parent | a933582f3e1d9bab55c27d4a64fa62b55a145d8c (diff) | |
download | bionic-899d809bca0cbe61a18b376dafdfcdb578324a9e.tar.gz |
Merge "__system_property_set: add string names for init's error codes." into main
-rw-r--r-- | libc/bionic/system_property_set.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libc/bionic/system_property_set.cpp b/libc/bionic/system_property_set.cpp index 6e49bced6..73cf15190 100644 --- a/libc/bionic/system_property_set.cpp +++ b/libc/bionic/system_property_set.cpp @@ -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; } |