[openib-general] [PATCH] kDAPL: remove redundant kfree checks

Tom Duffy tduffy at sun.com
Thu Jun 30 16:01:31 PDT 2005


kfree() already checks for NULL.  No need to do it twice.

Signed-off-by: Tom Duffy <tduffy at sun.com>

Index: linux-kernel/dat-provider/dapl_cookie.c
===================================================================
--- linux-kernel/dat-provider/dapl_cookie.c	(revision 2761)
+++ linux-kernel/dat-provider/dapl_cookie.c	(working copy)
@@ -157,8 +157,7 @@ u32 dapl_cb_create(struct dapl_cookie_bu
  */
 void dapl_cb_free(struct dapl_cookie_buffer *buffer)
 {
-	if (NULL != buffer->pool) 
-		kfree(buffer->pool);
+	kfree(buffer->pool);
 }
 
 /*
Index: linux-kernel/dat-provider/dapl_ring_buffer_util.c
===================================================================
--- linux-kernel/dat-provider/dapl_ring_buffer_util.c	(revision 2761)
+++ linux-kernel/dat-provider/dapl_ring_buffer_util.c	(working copy)
@@ -149,7 +149,7 @@ bail:
  */
 void dapl_rbuf_destroy(struct dapl_ring_buffer *rbuf)
 {
-	if ((NULL == rbuf) || (NULL == rbuf->base))
+	if (!rbuf)
 		return;
 
 	kfree(rbuf->base);
Index: linux-kernel/dat-provider/dapl_ep.c
===================================================================
--- linux-kernel/dat-provider/dapl_ep.c	(revision 2761)
+++ linux-kernel/dat-provider/dapl_ep.c	(working copy)
@@ -47,11 +47,9 @@ static void dapl_ep_dealloc(struct dapl_
 	dapl_cb_free(&ep->req_buffer);
 	dapl_cb_free(&ep->recv_buffer);
 
-	if (ep->recv_iov)
-		kfree(ep->recv_iov);
+	kfree(ep->recv_iov);
 
-	if (ep->send_iov)
-		kfree(ep->send_iov);
+	kfree(ep->send_iov);
 
 	kfree(ep);
 }
Index: linux-kernel/dat-provider/dapl_evd.c
===================================================================
--- linux-kernel/dat-provider/dapl_evd.c	(revision 2761)
+++ linux-kernel/dat-provider/dapl_evd.c	(working copy)
@@ -265,9 +265,7 @@ static u32 dapl_evd_dealloc(struct dapl_
 	dapl_rbuf_destroy(&evd->free_event_queue);
 	dapl_rbuf_destroy(&evd->pending_event_queue);
 
-	if (evd->events) {
-		kfree(evd->events);
-	}
+	kfree(evd->events);
 
 	kfree(evd);
 
Index: linux-kernel/dat/api.c
===================================================================
--- linux-kernel/dat/api.c	(revision 2761)
+++ linux-kernel/dat/api.c	(working copy)
@@ -524,8 +524,7 @@ out_unlock:
 	spin_unlock_irqrestore(&dat_provider_list_lock, flags);
 out:
 	if (status != DAT_SUCCESS)
-		if (entry)
-			kfree(entry);
+		kfree(entry);
 	return status;
 }
 EXPORT_SYMBOL(dat_registry_add_provider);




More information about the general mailing list