Re: [ModemManager] [PATCH] mm_gsm_parse_scan_response(): Improve regex-construction error handling

2011-12-02 Thread Dan Williams
On Wed, 2011-11-30 at 17:33 -0500, Nathan Williams wrote:
> And this time with the patch.

Pushed, thanks.

Dan

> - Nathan
> 
> On Wed, Nov 30, 2011 at 2:07 PM, Nathan Williams  wrote:
> > This was the only code in ModemManager using g_error(), and not
> > appropriately, I think.
> > The codebase is still mixed on how to handle errors compiling regular
> > expressions; other places in this file use g_assert(), while the rest
> > of the code tends to report some kind of parse-failure error. Perhaps
> > this makes sense in terms of startup versus while-running operations?
> >
> >- Nathan
> >
> ___
> networkmanager-list mailing list
> networkmanager-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list


___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [ModemManager] [PATCH] mm_gsm_parse_scan_response(): Improve regex-construction error handling

2011-11-30 Thread Nathan Williams
And this time with the patch.

- Nathan

On Wed, Nov 30, 2011 at 2:07 PM, Nathan Williams  wrote:
> This was the only code in ModemManager using g_error(), and not
> appropriately, I think.
> The codebase is still mixed on how to handle errors compiling regular
> expressions; other places in this file use g_assert(), while the rest
> of the code tends to report some kind of parse-failure error. Perhaps
> this makes sense in terms of startup versus while-running operations?
>
>    - Nathan
>
From 41c12498c4d3b2c27ccd322e496d7001cfc6047f Mon Sep 17 00:00:00 2001
From: Nathan Williams 
Date: Wed, 30 Nov 2011 14:02:00 -0500
Subject: [PATCH] mm_gsm_parse_scan_response(): Improve 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
---
 src/mm-modem-helpers.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index fe0ba7a..912d9ba 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -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,
-- 
1.7.3.1

___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [ModemManager] [PATCH] mm_gsm_parse_scan_response(): Improve regex-construction error handling

2011-11-30 Thread Aleksander Morgado

> This was the only code in ModemManager using g_error(), and not
> appropriately, I think.
> The codebase is still mixed on how to handle errors compiling regular
> expressions; other places in this file use g_assert(), while the rest
> of the code tends to report some kind of parse-failure error. Perhaps
> this makes sense in terms of startup versus while-running operations?
> 

I would treat the errors compiling regular expressions as programmer
errors, and just use asserts, if anything.

-- 
Aleksander

___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


[ModemManager] [PATCH] mm_gsm_parse_scan_response(): Improve regex-construction error handling

2011-11-30 Thread Nathan Williams
This was the only code in ModemManager using g_error(), and not
appropriately, I think.
The codebase is still mixed on how to handle errors compiling regular
expressions; other places in this file use g_assert(), while the rest
of the code tends to report some kind of parse-failure error. Perhaps
this makes sense in terms of startup versus while-running operations?

- Nathan
___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list