From 8b72ea3f251bb3fbbb369a53848a01d86afe1927 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Fri, 28 Aug 2015 15:59:26 -0700 Subject: [PATCH] DO NOT MERGE init: Fix parsing of multiple property triggers Triggers of the form on property:a=b && property:b=c are only triggered on the transition of a->b (given that b=c), but not on the transition of b->c (given that a=b). This commit allows both transitions to trigger the property as expected Bug 23631258 Change-Id: I9f70b4cbf36f8a99d10c37ad049ae8ceb378d610 --- init/init_parser.cpp | 45 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/init/init_parser.cpp b/init/init_parser.cpp index 62e8b102d..9bab67d8d 100644 --- a/init/init_parser.cpp +++ b/init/init_parser.cpp @@ -572,7 +572,7 @@ void queue_property_triggers(const char *name, const char *value) list_for_each(node, &action_list) { act = node_to_item(node, struct action, alist); - match = !name; + match = !name; list_for_each(node2, &act->triggers) { cur_trigger = node_to_item(node2, struct trigger, nlist); if (!strncmp(cur_trigger->name, "property:", strlen("property:"))) { @@ -586,29 +586,28 @@ void queue_property_triggers(const char *name, const char *value) match = true; continue; } - } 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; + } + 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; - /* does the property exist, and match the trigger value? */ - ret = property_get(prop_name, value); - if (ret > 0 && (!strcmp(equals + 1, value) || - !strcmp(equals + 1, "*"))) { - continue; - } - } - } - } - } - match = false; - break; + /* does the property exist, and match the trigger value? */ + ret = property_get(prop_name, value); + if (ret > 0 && (!strcmp(equals + 1, value) || + !strcmp(equals + 1, "*"))) { + continue; + } + } + } + } + match = false; + break; } if (match) { action_add_queue_tail(act);