diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-06-07 20:36:40 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-06-07 20:36:40 -0500 |
commit | 1d8bb1bab67562ec68cef09429894e9916b4cb53 (patch) | |
tree | 651276d2f22b1020603728bc6fca55fd96198e5b | |
parent | 719842ea39145409e20295d4817203a613cd4bdb (diff) |
atmodem: Fix CPUC parser
Apparently some modems are extra stupid:
AT+CPUC?\r
\r\n+CPUC: \r\nOK\r\n
So if we fail to parse the response, return an error
-rw-r--r-- | drivers/atmodem/call-meter.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/atmodem/call-meter.c b/drivers/atmodem/call-meter.c index 0553d78c..422056eb 100644 --- a/drivers/atmodem/call-meter.c +++ b/drivers/atmodem/call-meter.c @@ -247,18 +247,24 @@ static void cpuc_query_cb(gboolean ok, g_at_result_iter_init(&iter, result); - if (!g_at_result_iter_next(&iter, cbd->user)) { - CALLBACK_WITH_FAILURE(cb, 0, 0, cbd->data); - return; - } + if (g_at_result_iter_next(&iter, cbd->user) != TRUE) + goto error; + + if (g_at_result_iter_next_string(&iter, ¤cy) != TRUE) + goto error; - g_at_result_iter_next_string(&iter, ¤cy); strncpy(currency_buf, currency, sizeof(currency_buf)); - g_at_result_iter_next_string(&iter, &ppu); + if (g_at_result_iter_next_string(&iter, &ppu) != TRUE) + goto error; + ppuval = strtod(ppu, NULL); cb(&error, currency_buf, ppuval, cbd->data); + return; + +error: + CALLBACK_WITH_FAILURE(cb, 0, 0, cbd->data); } static void at_cpuc_query(struct ofono_call_meter *cm, |