[PATCH v2] core: process SMS +CGMR response with regex

Nick Stevens Nick.Stevens at digi.com
Wed Sep 16 06:13:56 PDT 2015


On Wed, Sep 16, 2015 at 09:21:48AM +0200, Aleksander Morgado wrote:
> On Wed, Sep 16, 2015 at 12:26 AM, Dan Williams <dcbw at redhat.com> wrote:
> >> +    /* +CMGR: <stat>,<alpha>,<length>(whitespace)<pdu> */
> >> +    /* The <alpha> and <length> fields are matched, but not currently used */
> >> +    r = g_regex_new ("\\+CMGR:\\s*(\\d+)\\s*,([^,]*),\\s*(\\d+)\\s*([^\\r\\n]*)", 0, 0, error);
> >> +    g_assert (r != NULL);
> >
> > You could also do g_assert_no_error (error) before the g_assert(r) too.
> 
> Passing the error here in g_regex_new() with a constant pattern isn't
> very useful; if you didn't get an error in the regex when you tested
> it, no one will get it. So either g_assert_no_error() as Dan suggests
> or just pass NULL instead of error.

Passing NULL makes sense to me - you're right that checking the error here
isn't really adding anything.

Nick

> 
> 
> -- 
> Aleksander
> https://aleksander.es


More information about the ModemManager-devel mailing list