Merge "add checks for initialization for system properties"
am: 136bf8fa45
* commit '136bf8fa45b243b56a8f2543d43970f253118cd7':
add checks for initialization for system properties
This commit is contained in:
commit
e049fa71cb
@ -1006,6 +1006,10 @@ unsigned int __system_property_area_serial()
|
||||
|
||||
const prop_info *__system_property_find(const char *name)
|
||||
{
|
||||
if (!__system_property_area__) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (__predict_false(compat_mode)) {
|
||||
return __system_property_find_compat(name);
|
||||
}
|
||||
@ -1091,11 +1095,15 @@ int __system_property_set(const char *key, const char *value)
|
||||
|
||||
int __system_property_update(prop_info *pi, const char *value, unsigned int len)
|
||||
{
|
||||
prop_area *pa = __system_property_area__;
|
||||
|
||||
if (len >= PROP_VALUE_MAX)
|
||||
return -1;
|
||||
|
||||
prop_area* pa = __system_property_area__;
|
||||
|
||||
if (!pa) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t serial = atomic_load_explicit(&pi->serial, memory_order_relaxed);
|
||||
serial |= 1;
|
||||
atomic_store_explicit(&pi->serial, serial, memory_order_relaxed);
|
||||
@ -1129,6 +1137,10 @@ int __system_property_add(const char *name, unsigned int namelen,
|
||||
if (namelen < 1)
|
||||
return -1;
|
||||
|
||||
if (!__system_property_area__) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
prop_area* pa = get_prop_area_for_name(name);
|
||||
|
||||
if (!pa) {
|
||||
@ -1168,6 +1180,10 @@ unsigned int __system_property_wait_any(unsigned int serial)
|
||||
prop_area *pa = __system_property_area__;
|
||||
uint32_t my_serial;
|
||||
|
||||
if (!pa) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
do {
|
||||
__futex_wait(pa->serial(), serial, NULL);
|
||||
my_serial = atomic_load_explicit(pa->serial(), memory_order_acquire);
|
||||
@ -1191,6 +1207,10 @@ const prop_info *__system_property_find_nth(unsigned n)
|
||||
int __system_property_foreach(void (*propfn)(const prop_info *pi, void *cookie),
|
||||
void *cookie)
|
||||
{
|
||||
if (!__system_property_area__) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (__predict_false(compat_mode)) {
|
||||
return __system_property_foreach_compat(propfn, cookie);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user