[PATCH 3/5] telit: remove unnecessary NULL checks for g_free / g_match_info_free

Aleksander Morgado aleksander at aleksander.es
Wed Jul 12 09:07:07 UTC 2017


On 12/07/17 10:03, Ben Chan wrote:
> g_free() and g_match_info_free() already check if the given pointer is
> NULL and does nothing on a NULL pointer.
> ---
>  plugins/telit/mm-modem-helpers-telit.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 

Pushed to git master, thanks!

> diff --git a/plugins/telit/mm-modem-helpers-telit.c b/plugins/telit/mm-modem-helpers-telit.c
> index d0e50ab3..75667fd0 100644
> --- a/plugins/telit/mm-modem-helpers-telit.c
> +++ b/plugins/telit/mm-modem-helpers-telit.c
> @@ -308,9 +308,7 @@ end:
>      if (!ret && bands != NULL)
>          g_array_free (bands, TRUE);
>  
> -    if(match_info)
> -        g_match_info_free (match_info);
> -
> +    g_match_info_free (match_info);
>      g_regex_unref (r);
>  
>      return ret;
> @@ -361,8 +359,7 @@ mm_telit_get_2g_mm_bands (GMatchInfo *match_info,
>      }
>  
>  end:
> -    if (match_str != NULL)
> -        g_free (match_str);
> +    g_free (match_str);
>  
>      if (flags != NULL)
>          g_array_free (flags, TRUE);
> @@ -432,8 +429,7 @@ mm_telit_get_3g_mm_bands (GMatchInfo *match_info,
>      }
>  
>  end:
> -    if (match_str != NULL)
> -        g_free (match_str);
> +    g_free (match_str);
>  
>      if (flags != NULL)
>          g_array_free (flags, TRUE);
> @@ -486,8 +482,7 @@ mm_telit_get_4g_mm_bands(GMatchInfo *match_info,
>          value = value >> 1;
>      }
>  end:
> -    if (match_str != NULL)
> -        g_free (match_str);
> +    g_free (match_str);
>  
>      return ret;
>  }
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list