summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwalter harms <wharms@bfs.de>2017-09-08 19:59:17 +0200
committerEmil Velikov <emil.l.velikov@gmail.com>2017-09-14 09:03:11 +0100
commit936dcaac07f7db569ed91a34e0a4b5944aac205f (patch)
tree0edc1bf5f7a2f6671dbf5b1decce37e8281be9a2
parent43644931cb9cb5cc92391f6f5431535b9b7a3f24 (diff)
Drop NULL check prior to free()
free() can handle NULL just fine - remove the check. Signed-off-by: Walter Harms <wharms@bfs.de> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
-rw-r--r--src/authutil.c24
-rw-r--r--src/misc.c3
-rw-r--r--src/process.c41
-rw-r--r--src/shutdown.c44
4 files changed, 39 insertions, 73 deletions
diff --git a/src/authutil.c b/src/authutil.c
index 89ba199..e3bad01 100644
--- a/src/authutil.c
+++ b/src/authutil.c
@@ -110,8 +110,8 @@ IceAuthFileName (void)
if (size > bsize)
{
- if (buf)
- free (buf);
+
+ free (buf);
buf = malloc (size);
if (!buf) {
bsize = 0;
@@ -265,11 +265,11 @@ IceReadAuthFileEntry (
bad:
- if (local.protocol_name) free (local.protocol_name);
- if (local.protocol_data) free (local.protocol_data);
- if (local.network_id) free (local.network_id);
- if (local.auth_name) free (local.auth_name);
- if (local.auth_data) free (local.auth_data);
+ free (local.protocol_name);
+ free (local.protocol_data);
+ free (local.network_id);
+ free (local.auth_name);
+ free (local.auth_data);
return (NULL);
}
@@ -283,11 +283,11 @@ IceFreeAuthFileEntry (
{
if (auth)
{
- if (auth->protocol_name) free (auth->protocol_name);
- if (auth->protocol_data) free (auth->protocol_data);
- if (auth->network_id) free (auth->network_id);
- if (auth->auth_name) free (auth->auth_name);
- if (auth->auth_data) free (auth->auth_data);
+ free (auth->protocol_name);
+ free (auth->protocol_data);
+ free (auth->network_id);
+ free (auth->auth_name);
+ free (auth->auth_data);
free (auth);
}
}
diff --git a/src/misc.c b/src/misc.c
index 62285e9..0d5fadd 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -54,8 +54,7 @@ IceAllocScratch (
{
if (!iceConn->scratch || size > iceConn->scratch_size)
{
- if (iceConn->scratch)
- free (iceConn->scratch);
+ free (iceConn->scratch);
iceConn->scratch = malloc (size);
iceConn->scratch_size = size;
diff --git a/src/process.c b/src/process.c
index 5e00be3..fae081b 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1036,8 +1036,7 @@ ProcessConnectionSetup (
iceConn->connection_status = IceConnectRejected;
}
- if (hostname)
- free (hostname);
+ free (hostname);
}
if (iceConn->connection_status == IceConnectRejected)
@@ -1090,8 +1089,7 @@ ProcessConnectionSetup (
if (authData && authDataLen > 0)
free (authData);
- if (errorString)
- free (errorString);
+ free (errorString);
}
if (accept_setup_now)
@@ -1379,8 +1377,7 @@ ProcessAuthReply (
status = IcePaAuthAccepted;
}
- if (hostname)
- free (hostname);
+ free (hostname);
}
if (status != IcePaAuthAccepted)
@@ -1454,8 +1451,7 @@ ProcessAuthReply (
status = IcePaAuthAccepted;
}
- if (hostname)
- free (hostname);
+ free (hostname);
}
if (status == IcePaAuthRejected)
@@ -1569,18 +1565,15 @@ ProcessAuthReply (
_IceErrorSetupFailed (iceConn, ICE_ProtocolSetup,
failureReason);
- if (failureReason)
- free (failureReason);
+ free (failureReason);
}
}
if (free_setup_info)
{
- if (iceConn->protosetup_to_me->his_vendor)
- free (iceConn->protosetup_to_me->his_vendor);
- if (iceConn->protosetup_to_me->his_release)
- free (iceConn->protosetup_to_me->his_release);
+ free (iceConn->protosetup_to_me->his_vendor);
+ free (iceConn->protosetup_to_me->his_release);
free (iceConn->protosetup_to_me);
iceConn->protosetup_to_me = NULL;
}
@@ -1597,8 +1590,8 @@ ProcessAuthReply (
if (authData && authDataLen > 0)
free (authData);
- if (errorString)
- free (errorString);
+
+ free (errorString);
IceDisposeCompleteMessage (iceConn, replyData);
return (0);
@@ -2081,8 +2074,7 @@ ProcessProtocolSetup (
ICE_ProtocolSetup, "None of the authentication protocols specified are supported and host-based authentication failed");
}
- if (hostname)
- free (hostname);
+ free (hostname);
}
}
else
@@ -2128,8 +2120,8 @@ ProcessProtocolSetup (
if (authData && authDataLen > 0)
free (authData);
- if (errorString)
- free (errorString);
+
+ free (errorString);
}
if (accept_setup_now)
@@ -2212,16 +2204,13 @@ ProcessProtocolSetup (
_IceErrorSetupFailed (iceConn, ICE_ProtocolSetup, failureReason);
- if (failureReason)
- free (failureReason);
+ free (failureReason);
}
}
- if (vendor)
- free (vendor);
- if (release)
- free (release);
+ free (vendor);
+ free (release);
if (hisAuthCount > 0)
{
diff --git a/src/shutdown.c b/src/shutdown.c
index 3fafb10..3f0880b 100644
--- a/src/shutdown.c
+++ b/src/shutdown.c
@@ -282,39 +282,17 @@ _IceFreeConnection (
if (iceConn->trans_conn)
_IceTransClose (iceConn->trans_conn);
- if (iceConn->connection_string)
- free (iceConn->connection_string);
-
- if (iceConn->vendor)
- free (iceConn->vendor);
-
- if (iceConn->release)
- free (iceConn->release);
-
- if (iceConn->inbuf)
- free (iceConn->inbuf);
-
- if (iceConn->outbuf)
- free (iceConn->outbuf);
-
- if (iceConn->scratch)
- free (iceConn->scratch);
-
- if (iceConn->process_msg_info)
- free (iceConn->process_msg_info);
-
- if (iceConn->connect_to_you)
- free (iceConn->connect_to_you);
-
- if (iceConn->protosetup_to_you)
- free (iceConn->protosetup_to_you);
-
- if (iceConn->connect_to_me)
- free (iceConn->connect_to_me);
-
- if (iceConn->protosetup_to_me)
- free (iceConn->protosetup_to_me);
-
+ free (iceConn->connection_string);
+ free (iceConn->vendor);
+ free (iceConn->release);
+ free (iceConn->inbuf);
+ free (iceConn->outbuf);
+ free (iceConn->scratch);
+ free (iceConn->process_msg_info);
+ free (iceConn->connect_to_you);
+ free (iceConn->protosetup_to_you);
+ free (iceConn->connect_to_me);
+ free (iceConn->protosetup_to_me);
free (iceConn);
}