From 964ae3606a2a999ff1b0c012175cf89326e7928e Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 23 Feb 2011 11:17:28 -0600 Subject: [PATCH] emulator: Reflow the code slightly --- src/emulator.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/emulator.c b/src/emulator.c index e6f503d8..f0ca8c89 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -273,7 +273,6 @@ static void emulator_add_indicator(struct ofono_emulator *em, const char* name, static void emulator_unregister(struct ofono_atom *atom) { struct ofono_emulator *em = __ofono_atom_get_data(atom); - struct indicator *ind; GSList *l; DBG("%p", em); @@ -284,11 +283,12 @@ static void emulator_unregister(struct ofono_atom *atom) } for (l = em->indicators; l; l = l->next) { - ind = l->data; + struct indicator *ind = l->data; g_free(ind->name); g_free(ind); } + g_slist_free(em->indicators); em->indicators = NULL; @@ -534,23 +534,21 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em, int i; char buf[20]; - i = 1; - for (l = em->indicators; l; l = l->next) { + for (i = 1, l = em->indicators; l; l = l->next, i++) { struct indicator *ind = l->data; - if (g_str_equal(ind->name, name)) { - if (ind->value == value || value < ind->min + if (g_str_equal(ind->name, name) == FALSE) + continue; + + if (ind->value == value || value < ind->min || value > ind->max) - return; + return; - ind->value = value; + ind->value = value; - sprintf(buf, "+CIEV: %d,%d", i, ind->value); - g_at_server_send_info(em->server, buf, TRUE); + sprintf(buf, "+CIEV: %d,%d", i, ind->value); + g_at_server_send_info(em->server, buf, TRUE); - break; - } - - i++; + return; } }