[PATCH 2/3] core: remove unnecessary NULL checks for g_match_info_free()

Ben Chan benchan at chromium.org
Thu Oct 18 06:06:48 UTC 2018


g_match_info_free() already check if the given pointer is NULL and does
nothing on a NULL pointer.
---
 .../cinterion/mm-modem-helpers-cinterion.c    | 12 ++++------
 plugins/huawei/mm-modem-helpers-huawei.c      | 21 ++++++----------
 plugins/mbm/mm-modem-helpers-mbm.c            |  3 +--
 plugins/mtk/mm-broadband-modem-mtk.c          | 13 ++++------
 plugins/novatel/mm-broadband-modem-novatel.c  |  3 +--
 plugins/sierra/mm-broadband-modem-sierra.c    |  6 ++---
 plugins/sierra/mm-modem-helpers-sierra.c      |  3 +--
 plugins/ublox/mm-modem-helpers-ublox.c        | 24 +++++++------------
 plugins/wavecom/mm-broadband-modem-wavecom.c  |  3 +--
 plugins/xmm/mm-modem-helpers-xmm.c            | 10 +++-----
 plugins/zte/mm-broadband-modem-zte.c          |  3 +--
 src/mm-modem-helpers.c                        | 24 ++++++-------------
 12 files changed, 40 insertions(+), 85 deletions(-)

diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.c b/plugins/cinterion/mm-modem-helpers-cinterion.c
index 86cea6c1..2afd11a4 100644
--- a/plugins/cinterion/mm-modem-helpers-cinterion.c
+++ b/plugins/cinterion/mm-modem-helpers-cinterion.c
@@ -147,8 +147,7 @@ mm_cinterion_parse_scfg_test (const gchar *response,
         g_free (maxbandstr);
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (!bands)
@@ -234,8 +233,7 @@ mm_cinterion_parse_scfg_response (const gchar *response,
         g_free (currentstr);
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (!bands)
@@ -341,8 +339,7 @@ mm_cinterion_parse_cnmi_test (const gchar *response,
 
 out:
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -457,8 +454,7 @@ mm_cinterion_parse_sind_response (const gchar *response,
     } else
         errors++;
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (errors > 0) {
diff --git a/plugins/huawei/mm-modem-helpers-huawei.c b/plugins/huawei/mm-modem-helpers-huawei.c
index 2aac3d60..70de4f54 100644
--- a/plugins/huawei/mm-modem-helpers-huawei.c
+++ b/plugins/huawei/mm-modem-helpers-huawei.c
@@ -257,8 +257,7 @@ mm_huawei_parse_dhcp_response (const char *reply,
         }
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
     return matched;
 }
@@ -324,8 +323,7 @@ mm_huawei_parse_sysinfo_response (const char *reply,
         }
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
     return matched;
 }
@@ -389,8 +387,7 @@ mm_huawei_parse_sysinfoex_response (const char *reply,
         mm_get_uint_from_match_info (match_info, 8, out_sys_submode);
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
     return matched;
 }
@@ -1257,8 +1254,7 @@ gboolean mm_huawei_parse_nwtime_response (const gchar *response,
         }
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     return ret;
@@ -1329,8 +1325,7 @@ gboolean mm_huawei_parse_time_response (const gchar *response,
         }
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     return ret;
@@ -1400,8 +1395,7 @@ mm_huawei_parse_hcsq_response (const gchar *response,
     ret = TRUE;
 
 done:
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     return ret;
@@ -1463,8 +1457,7 @@ mm_huawei_parse_cvoice_response (const gchar  *response,
         }
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     return ret;
diff --git a/plugins/mbm/mm-modem-helpers-mbm.c b/plugins/mbm/mm-modem-helpers-mbm.c
index ca024ddb..18656e57 100644
--- a/plugins/mbm/mm-modem-helpers-mbm.c
+++ b/plugins/mbm/mm-modem-helpers-mbm.c
@@ -159,8 +159,7 @@ mm_mbm_parse_e2ipcfg_response (const gchar *response,
     }
 
 done:
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
     return !!*ip_config;
 }
diff --git a/plugins/mtk/mm-broadband-modem-mtk.c b/plugins/mtk/mm-broadband-modem-mtk.c
index 475a63ac..0f8aaf79 100644
--- a/plugins/mtk/mm-broadband-modem-mtk.c
+++ b/plugins/mtk/mm-broadband-modem-mtk.c
@@ -122,8 +122,7 @@ load_unlock_retries_ready (MMBaseModem *self,
     }
     g_object_unref (task);
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 }
 
@@ -224,8 +223,7 @@ get_supported_modes_ready (MMBaseModem *self,
                      response);
 
         g_regex_unref (r);
-        if (match_info)
-            g_match_info_free (match_info);
+        g_match_info_free (match_info);
         return;
     }
 
@@ -280,9 +278,7 @@ get_supported_modes_ready (MMBaseModem *self,
     g_object_unref (task);
 
     g_regex_unref (r);
-    if (match_info)
-        g_match_info_free (match_info);
-    return;
+    g_match_info_free (match_info);
 }
 
 static void
@@ -412,8 +408,7 @@ load_current_modes_finish (MMIfaceModem *self,
 done:
     if (r)
         g_regex_unref (r);
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
 
     return result;
 }
diff --git a/plugins/novatel/mm-broadband-modem-novatel.c b/plugins/novatel/mm-broadband-modem-novatel.c
index fdb4ba52..676d2c87 100644
--- a/plugins/novatel/mm-broadband-modem-novatel.c
+++ b/plugins/novatel/mm-broadband-modem-novatel.c
@@ -1158,8 +1158,7 @@ parse_nwltime_reply (const char *response,
     else
         g_free (result);
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
     return success;
 }
diff --git a/plugins/sierra/mm-broadband-modem-sierra.c b/plugins/sierra/mm-broadband-modem-sierra.c
index 7a99a9bf..21173c9a 100644
--- a/plugins/sierra/mm-broadband-modem-sierra.c
+++ b/plugins/sierra/mm-broadband-modem-sierra.c
@@ -727,8 +727,7 @@ selrat_query_ready (MMBaseModem *self,
                              "Could not parse allowed mode response: Response didn't match: '%s'",
                              response);
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (error) {
@@ -1382,8 +1381,7 @@ parse_time (const gchar *response,
         }
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
     return result;
 }
diff --git a/plugins/sierra/mm-modem-helpers-sierra.c b/plugins/sierra/mm-modem-helpers-sierra.c
index 14324614..2d5fd7da 100644
--- a/plugins/sierra/mm-modem-helpers-sierra.c
+++ b/plugins/sierra/mm-modem-helpers-sierra.c
@@ -67,8 +67,7 @@ mm_sierra_parse_scact_read_response (const gchar  *reply,
         g_match_info_next (match_info, &inner_error);
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
diff --git a/plugins/ublox/mm-modem-helpers-ublox.c b/plugins/ublox/mm-modem-helpers-ublox.c
index ff1a8488..b6fd34d9 100644
--- a/plugins/ublox/mm-modem-helpers-ublox.c
+++ b/plugins/ublox/mm-modem-helpers-ublox.c
@@ -78,8 +78,7 @@ mm_ublox_parse_upincnt_response (const gchar  *response,
 
 out:
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -144,8 +143,7 @@ mm_ublox_parse_uusbconf_response (const gchar        *response,
         g_free (profile_name);
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -205,8 +203,7 @@ mm_ublox_parse_ubmconf_response (const gchar            *response,
         }
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -292,8 +289,7 @@ mm_ublox_parse_uipaddr_response (const gchar  *response,
 
 out:
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -982,8 +978,7 @@ mm_ublox_parse_uact_response (const gchar  *response,
         g_free (bandstr);
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -1097,8 +1092,7 @@ mm_ublox_parse_uact_test (const gchar  *response,
 
 out:
     g_strfreev (split);
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -1229,8 +1223,7 @@ out:
     g_free (allowed_str);
     g_free (preferred_str);
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -1449,8 +1442,7 @@ mm_ublox_parse_ugcntrd_response_for_cid (const gchar  *response,
 
 out:
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
diff --git a/plugins/wavecom/mm-broadband-modem-wavecom.c b/plugins/wavecom/mm-broadband-modem-wavecom.c
index 5da6c232..51e50456 100644
--- a/plugins/wavecom/mm-broadband-modem-wavecom.c
+++ b/plugins/wavecom/mm-broadband-modem-wavecom.c
@@ -317,8 +317,7 @@ wwsm_read_ready (MMBaseModem  *self,
     g_object_unref (task);
 
     g_regex_unref (r);
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
 }
 
 static void
diff --git a/plugins/xmm/mm-modem-helpers-xmm.c b/plugins/xmm/mm-modem-helpers-xmm.c
index a3eb5f9b..4ccbc745 100644
--- a/plugins/xmm/mm-modem-helpers-xmm.c
+++ b/plugins/xmm/mm-modem-helpers-xmm.c
@@ -449,8 +449,7 @@ mm_xmm_parse_xact_query_response (const gchar             *response,
     /* success */
 
 out:
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -672,9 +671,7 @@ mm_xmm_parse_xcesq_query_response (const gchar  *response,
     }
 
 out:
-
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -996,8 +993,7 @@ mm_xmm_parse_xlcsslp_query_response (const gchar  *response,
     }
 
 out:
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
diff --git a/plugins/zte/mm-broadband-modem-zte.c b/plugins/zte/mm-broadband-modem-zte.c
index 575e7896..a1b24bc3 100644
--- a/plugins/zte/mm-broadband-modem-zte.c
+++ b/plugins/zte/mm-broadband-modem-zte.c
@@ -405,8 +405,7 @@ load_current_modes_finish (MMIfaceModem *self,
         g_assert_not_reached ();
 
 done:
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     if (r)
         g_regex_unref (r);
 
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 296b9f3a..7845edcf 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -1303,8 +1303,7 @@ mm_3gpp_parse_cops_read_response (const gchar              *response,
     }
 
 out:
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -1608,8 +1607,7 @@ mm_3gpp_parse_cgact_read_response (const gchar *reply,
         g_match_info_next (match_info, &inner_error);
     }
 
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -2152,9 +2150,7 @@ mm_3gpp_parse_cgcontrdp_response (const gchar  *response,
         dns_secondary_address = mm_get_string_unquoted_from_match_info (match_info, 7 + field_format_extra_index);
 
 out:
-
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     g_free (local_address_and_subnet);
@@ -2238,8 +2234,7 @@ mm_3gpp_parse_cfun_query_response (const gchar  *response,
     *out_state = state;
 
 out:
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -2317,9 +2312,7 @@ mm_3gpp_parse_cesq_response (const gchar  *response,
     }
 
 out:
-
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     if (inner_error) {
@@ -2725,8 +2718,7 @@ end:
     if (r != NULL)
         g_regex_unref (r);
 
-    if (match_info != NULL)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
 
     return ret;
 }
@@ -4321,9 +4313,7 @@ mm_parse_cclk_response (const char *response,
     ret = TRUE;
 
  out:
-
-    if (match_info)
-        g_match_info_free (match_info);
+    g_match_info_free (match_info);
     g_regex_unref (r);
 
     return ret;
-- 
2.19.1.568.g152ad8e336-goog



More information about the ModemManager-devel mailing list