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