diff options
author | Yabin Cui <yabinc@google.com> | 2015-07-24 10:11:05 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2015-07-24 11:14:08 -0700 |
commit | 74edcea90e31a3795e58aa1b2bbe96032f0bcd61 (patch) | |
tree | 1b2163806229cd03670484aad5a2d11ad1a3eed0 /init/init_parser.cpp | |
parent | 89cc750e9b2623aae3c257ce6c72f4ffe3e1bb33 (diff) |
init: Let property_get return std::string.
Bug: 22654233
Change-Id: Id6091f58432f75e966b9871256049fbe17766c10
Diffstat (limited to 'init/init_parser.cpp')
-rw-r--r-- | init/init_parser.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/init/init_parser.cpp b/init/init_parser.cpp index 956ed255a..41b89f14c 100644 --- a/init/init_parser.cpp +++ b/init/init_parser.cpp @@ -247,9 +247,7 @@ int expand_props(char *dst, const char *src, int dst_size) while (*src_ptr && left > 0) { char *c; char prop[PROP_NAME_MAX + 1]; - char prop_val[PROP_VALUE_MAX]; int prop_len = 0; - int prop_val_len; c = strchr(src_ptr, '$'); if (!c) { @@ -307,14 +305,14 @@ int expand_props(char *dst, const char *src, int dst_size) goto err; } - prop_val_len = property_get(prop, prop_val); - if (!prop_val_len) { + std::string prop_val = property_get(prop); + if (prop_val.empty()) { ERROR("property '%s' doesn't exist while expanding '%s'\n", prop, src); goto err; } - ret = push_chars(&dst_ptr, &left, prop_val, prop_val_len); + ret = push_chars(&dst_ptr, &left, prop_val.c_str(), prop_val.size()); if (ret < 0) goto err_nospace; src_ptr = c; @@ -586,17 +584,13 @@ void queue_property_triggers(const char *name, const char *value) } else { const char* equals = strchr(test, '='); if (equals) { - char prop_name[PROP_NAME_MAX + 1]; - char value[PROP_VALUE_MAX]; int length = equals - test; if (length <= PROP_NAME_MAX) { - int ret; - memcpy(prop_name, test, length); - prop_name[length] = 0; + std::string prop_name(test, length); + std::string value = property_get(prop_name.c_str()); /* does the property exist, and match the trigger value? */ - ret = property_get(prop_name, value); - if (ret > 0 && (!strcmp(equals + 1, value) || + if (!value.empty() && (!strcmp(equals + 1, value.c_str()) || !strcmp(equals + 1, "*"))) { continue; } |