gsm: improve scan response regex construction error handling

Change the error handling to be a bit more like what appears to have
been intended: if constructing the regex fails, report an error and
return. The existing code looked like it was set up to do this, but
wasn't quite wired together, and had process-terminating calls
(g_error()) followed by other code.

Change-Id: I4a7cee8fe01291976edc2e343fcbeb73e882f20b
This commit is contained in:
Nathan Williams
2011-11-30 17:33:39 -05:00
committed by Dan Williams
parent 58b2a79f83
commit c1e64f1a33

View File

@@ -112,9 +112,9 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
* +COPS: (2,"","T-Mobile","31026",0),(1,"AT&T","AT&T","310410"),0)
*/
r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^,\\)]*)[\\)]?,(\\d)\\)", G_REGEX_UNGREEDY, 0, NULL);
r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^,\\)]*)[\\)]?,(\\d)\\)", G_REGEX_UNGREEDY, 0, &err);
if (err) {
g_error ("Invalid regular expression: %s", err->message);
mm_err ("Invalid regular expression: %s", err->message);
g_error_free (err);
g_set_error_literal (error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
@@ -141,9 +141,9 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
* +COPS: (2,"T - Mobile",,"31026"),(1,"Einstein PCS",,"31064"),(1,"Cingular",,"31041"),,(0,1,3),(0,2)
*/
r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^\\)]*)\\)", G_REGEX_UNGREEDY, 0, NULL);
r = g_regex_new ("\\((\\d),([^,\\)]*),([^,\\)]*),([^\\)]*)\\)", G_REGEX_UNGREEDY, 0, &err);
if (err) {
g_error ("Invalid regular expression: %s", err->message);
mm_err ("Invalid regular expression: %s", err->message);
g_error_free (err);
g_set_error_literal (error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,