[PATCH 1/3] core: remove unnecessary NULL checks for g_free()
Ben Chan
benchan at chromium.org
Thu Oct 18 06:06:47 UTC 2018
g_free() already check if the given pointer is NULL and does nothing on
a NULL pointer.
---
libmm-glib/mm-location-gps-raw.c | 3 +--
src/mm-base-sms.c | 6 ++----
src/mm-broadband-bearer.c | 3 +--
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/libmm-glib/mm-location-gps-raw.c b/libmm-glib/mm-location-gps-raw.c
index 5241ba7c..4cfe7f08 100644
--- a/libmm-glib/mm-location-gps-raw.c
+++ b/libmm-glib/mm-location-gps-raw.c
@@ -217,8 +217,7 @@ mm_location_gps_raw_add_trace (MMLocationGpsRaw *self,
if (g_regex_match (self->priv->gga_regex, trace, 0, &match_info)) {
/* UTC time */
- if (self->priv->utc_time)
- g_free (self->priv->utc_time);
+ g_free (self->priv->utc_time);
self->priv->utc_time = g_match_info_fetch (match_info, 1);
/* Latitude */
diff --git a/src/mm-base-sms.c b/src/mm-base-sms.c
index f9c16013..e117bef7 100644
--- a/src/mm-base-sms.c
+++ b/src/mm-base-sms.c
@@ -215,10 +215,8 @@ generate_3gpp_submit_pdus (MMBaseSms *self,
}
/* Free array (not contents, which were taken for the part) */
- if (split_text)
- g_free (split_text);
- if (split_data)
- g_free (split_data);
+ g_free (split_text);
+ g_free (split_data);
/* Set additional multipart specific properties */
if (n_parts > 1) {
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index bf02c13a..1b13921a 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -1376,8 +1376,7 @@ detailed_disconnect_finish (MMBroadbandBearer *self,
static void
detailed_disconnect_context_free (DetailedDisconnectContext *ctx)
{
- if (ctx->cgact_command)
- g_free (ctx->cgact_command);
+ g_free (ctx->cgact_command);
g_object_unref (ctx->data);
g_object_unref (ctx->primary);
if (ctx->secondary)
--
2.19.1.568.g152ad8e336-goog
More information about the ModemManager-devel
mailing list