From 9c4a934a514a6f9363b1f0d7ba753ec8e9691744 Mon Sep 17 00:00:00 2001 From: Dylan Van Assche Date: Wed, 12 May 2021 16:41:48 +0200 Subject: [PATCH] at: g_free doesn't require NULL checking From the docs: If mem is NULL it simply returns, so there is no need to check mem against NULL before calling this function. --- src/at.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/at.c b/src/at.c index 358d95a..f5f9200 100644 --- a/src/at.c +++ b/src/at.c @@ -114,14 +114,10 @@ static void next_at_command(struct EG25Manager *manager) if (!at_cmd) return; - if (at_cmd->cmd) - g_free(at_cmd->cmd); - if (at_cmd->subcmd) - g_free(at_cmd->subcmd); - if (at_cmd->value) - g_free(at_cmd->value); - if (at_cmd->expected) - g_free(at_cmd->expected); + g_free(at_cmd->cmd); + g_free(at_cmd->subcmd); + g_free(at_cmd->value); + g_free(at_cmd->expected); g_free(at_cmd); manager->at_cmds = g_list_remove(manager->at_cmds, at_cmd); @@ -152,8 +148,7 @@ static void process_at_result(struct EG25Manager *manager, char *response) return; if (at_cmd->expected && !strstr(response, at_cmd->expected)) { - if (at_cmd->value) - g_free(at_cmd->value); + g_free(at_cmd->value); at_cmd->value = at_cmd->expected; at_cmd->expected = NULL; g_message("Got a different result than expected, changing value...");