aboutsummaryrefslogtreecommitdiff
path: root/plugins/wavecom
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2022-08-24 12:31:47 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2022-09-05 17:33:11 +0000
commit74fc5baca229922b244ad66d5819d6d765e2d9da (patch)
treeb8162255a86134a355481e4b72137d25efa39e20 /plugins/wavecom
parentb2a186b5c8c5f36fe02b8fab0f64fabf2878bc21 (diff)
core: port GRegex/GMatchInfo to use autoptr()
The behavior of GRegex changed in 2.73.2 once it was ported from pcre1 to pcre2. In some cases it was made more strict, which is fine, in other cases it exposed some change in how it behaves on certain matches that is not extremely clear whether it's ok or not. See https://gitlab.gnome.org/GNOME/glib/-/issues/2729 See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601 See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/621 Either way, one thing that was assumed was that initializing all GRegex/GMatchInfo variables to NULL and making sure they're NULL before they're initialized by glib (especially the GMatchInfo) was a good and safer approach. So, whenever possible, g_autoptr() is used to cleanup the allocated GMatchInfo/GRegex variables, and otherwise, g_clear_pointer() is used to ensure that no free/unref is attempted unless the given variable is not NULL, and also so that the variable is reseted to NULL after being disposed.
Diffstat (limited to 'plugins/wavecom')
-rw-r--r--plugins/wavecom/mm-broadband-modem-wavecom.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/plugins/wavecom/mm-broadband-modem-wavecom.c b/plugins/wavecom/mm-broadband-modem-wavecom.c
index 8659e1c4..521e72de 100644
--- a/plugins/wavecom/mm-broadband-modem-wavecom.c
+++ b/plugins/wavecom/mm-broadband-modem-wavecom.c
@@ -1223,9 +1223,9 @@ modem_power_off (MMIfaceModem *self,
static void
setup_ports (MMBroadbandModem *self)
{
- gpointer parser;
- MMPortSerialAt *primary;
- GRegex *regex;
+ gpointer parser;
+ MMPortSerialAt *primary;
+ g_autoptr(GRegex) regex = NULL;
/* Call parent's setup ports first always */
MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_wavecom_parent_class)->setup_ports (self);
@@ -1242,7 +1242,6 @@ setup_ports (MMBroadbandModem *self)
G_REGEX_RAW | G_REGEX_OPTIMIZE,
0, NULL);
mm_serial_parser_v1_set_custom_regex (parser, regex, NULL);
- g_regex_unref (regex);
mm_port_serial_at_set_response_parser (MM_PORT_SERIAL_AT (primary),
mm_serial_parser_v1_parse,