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

2018-10-18 Thread Aleksander Morgado
On 10/18/18 8:06 AM, Ben Chan wrote:
> g_match_info_free() already check if the given pointer is NULL and does
> nothing on a NULL pointer.
> ---

Pushed to git master, thanks.

>  .../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 

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

2018-10-18 Thread Ben Chan
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);