free() can handle NULL so remove the check Signed-off-by: Walter Harms <wha...@bfs.de> --- src/authutil.c | 24 ++++++++++++------------ src/misc.c | 3 +-- src/process.c | 41 +++++++++++++++-------------------------- src/shutdown.c | 44 +++++++++++--------------------------------- 4 files changed, 39 insertions(+), 73 deletions(-)
diff --git a/src/authutil.c b/src/authutil.c index ca0504a..d7bcef9 100644 --- a/src/authutil.c +++ b/src/authutil.c @@ -111,8 +111,8 @@ IceAuthFileName (void) if (size > bsize) { - if (buf) - free (buf); + + free (buf); buf = malloc (size); if (!buf) { bsize = 0; @@ -266,11 +266,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); } @@ -284,11 +284,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 d2e9150..87d6335 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 4100a83..a9a8d08 100644 --- a/src/process.c +++ b/src/process.c @@ -1026,8 +1026,7 @@ ProcessConnectionSetup ( iceConn->connection_status = IceConnectRejected; } - if (hostname) - free (hostname); + free (hostname); } if (iceConn->connection_status == IceConnectRejected) @@ -1080,8 +1079,7 @@ ProcessConnectionSetup ( if (authData && authDataLen > 0) free (authData); - if (errorString) - free (errorString); + free (errorString); } if (accept_setup_now) @@ -1369,8 +1367,7 @@ ProcessAuthReply ( status = IcePaAuthAccepted; } - if (hostname) - free (hostname); + free (hostname); } if (status != IcePaAuthAccepted) @@ -1444,8 +1441,7 @@ ProcessAuthReply ( status = IcePaAuthAccepted; } - if (hostname) - free (hostname); + free (hostname); } if (status == IcePaAuthRejected) @@ -1559,18 +1555,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; } @@ -1587,8 +1580,8 @@ ProcessAuthReply ( if (authData && authDataLen > 0) free (authData); - if (errorString) - free (errorString); + + free (errorString); IceDisposeCompleteMessage (iceConn, replyData); return (0); @@ -2071,8 +2064,7 @@ ProcessProtocolSetup ( ICE_ProtocolSetup, "None of the authentication protocols specified are supported and host-based authentication failed"); } - if (hostname) - free (hostname); + free (hostname); } } else @@ -2118,8 +2110,8 @@ ProcessProtocolSetup ( if (authData && authDataLen > 0) free (authData); - if (errorString) - free (errorString); + + free (errorString); } if (accept_setup_now) @@ -2202,16 +2194,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 5def0b4..90e9ded 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); } -- 2.1.4 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel