modem-helpers: ensure error is set when +CRM response parser doesn't match
This commit is contained in:
@@ -2021,7 +2021,8 @@ mm_cdma_parse_crm_test_response (const gchar *reply,
|
|||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
GRegex *r;
|
GRegex *r;
|
||||||
|
GMatchInfo *match_info = NULL;
|
||||||
|
GError *match_error = NULL;
|
||||||
|
|
||||||
/* Expected reply format is:
|
/* Expected reply format is:
|
||||||
* ---> AT+CRM=?
|
* ---> AT+CRM=?
|
||||||
@@ -2031,10 +2032,9 @@ mm_cdma_parse_crm_test_response (const gchar *reply,
|
|||||||
r = g_regex_new ("\\+CRM:\\s*\\((\\d+)-(\\d+)\\)",
|
r = g_regex_new ("\\+CRM:\\s*\\((\\d+)-(\\d+)\\)",
|
||||||
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
|
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
|
||||||
0, error);
|
0, error);
|
||||||
if (r) {
|
g_assert (r != NULL);
|
||||||
GMatchInfo *match_info = NULL;
|
|
||||||
|
|
||||||
if (g_regex_match_full (r, reply, strlen (reply), 0, 0, &match_info, error)) {
|
if (g_regex_match_full (r, reply, strlen (reply), 0, 0, &match_info, &match_error)) {
|
||||||
gchar *aux;
|
gchar *aux;
|
||||||
guint min_val = 0;
|
guint min_val = 0;
|
||||||
guint max_val = 0;
|
guint max_val = 0;
|
||||||
@@ -2065,11 +2065,18 @@ mm_cdma_parse_crm_test_response (const gchar *reply,
|
|||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (match_error) {
|
||||||
|
g_propagate_error (error, match_error);
|
||||||
|
} else {
|
||||||
|
g_set_error (error,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_FAILED,
|
||||||
|
"Couldn't parse CRM range: response didn't match (%s)",
|
||||||
|
reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_match_info_free (match_info);
|
g_match_info_free (match_info);
|
||||||
g_regex_unref (r);
|
g_regex_unref (r);
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user