ofono_devinfo_query_cb_t cb = cbd->cb;
const char *prefix = cbd->user;
struct ofono_error error;
+ int numlines = g_at_result_num_response_lines(result);
+ GAtResultIter iter;
+ const char *line;
+ int i;
decode_at_error(&error, g_at_result_final_response(result));
-
dump_response("attr_cb", ok, result);
- if (ok) {
- GAtResultIter iter;
- const char *line;
- int i;
+ if (!ok) {
+ cb(&error, NULL, cbd->data);
+ return;
+ }
+
+ if (numlines == 0) {
+ CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+ return;
+ }
- g_at_result_iter_init(&iter, result);
+ g_at_result_iter_init(&iter, result);
- /* We have to be careful here, sometimes a stray unsolicited
- * notification will appear as part of the response and we
- * cannot rely on having a prefix to recognize the actual
- * response line. So use the last line only as the response
- */
- for (i = 0; i < g_at_result_num_response_lines(result); i++)
- g_at_result_iter_next(&iter, NULL);
+ /* We have to be careful here, sometimes a stray unsolicited
+ * notification will appear as part of the response and we
+ * cannot rely on having a prefix to recognize the actual
+ * response line. So use the last line only as the response
+ */
+ for (i = 0; i < numlines; i++)
+ g_at_result_iter_next(&iter, NULL);
- line = g_at_result_iter_raw_line(&iter);
+ line = g_at_result_iter_raw_line(&iter);
- cb(&error, fixup_return(line, prefix), cbd->data);
- } else
- cb(&error, "", cbd->data);
+ cb(&error, fixup_return(line, prefix), cbd->data);
}
static void at_query_manufacturer(struct ofono_devinfo *info,