[openib-general] [PATCH] kDAPL no need to cast kmalloc()'s return

Tom Duffy tduffy at sun.com
Fri May 20 12:28:41 PDT 2005


On Fri, 2005-05-20 at 10:58 -0700, Sean Hefty wrote:
> Also, do we need any of the casts before the kmallocs?

This patch removes the cast before kmalloc().  It also makes sure to
check the return of kmalloc() -- was missing in one spot in
dapl_ep_connect.c.  Make the NULL check (relatively) consistent across
the code.

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

diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat/dictionary.c linux-kernel-kmallc/dat/dictionary.c
--- linux-kernel-sizeof/dat/dictionary.c	2005-05-20 09:55:56.230003000 -0700
+++ linux-kernel-kmallc/dat/dictionary.c	2005-05-20 12:07:59.344001000 -0700
@@ -97,7 +97,7 @@ u32 dat_dictionary_entry_create(struct d
 	BUG_ON(NULL == p_entry);
 
 	entry = kmalloc(sizeof *entry, GFP_ATOMIC);
-	if (NULL == entry) {
+	if (!entry) {
 		status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat/dr.c linux-kernel-kmallc/dat/dr.c
--- linux-kernel-sizeof/dat/dr.c	2005-05-20 09:56:11.726007000 -0700
+++ linux-kernel-kmallc/dat/dr.c	2005-05-20 12:08:31.954000000 -0700
@@ -85,7 +85,7 @@ u32 dat_dr_insert(const struct dat_provi
 	u32 status;
 
 	data = kmalloc(sizeof *data, GFP_ATOMIC);
-	if (NULL == data) {
+	if (!data) {
 		status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 
 				   DAT_RESOURCE_MEMORY);
 		goto bail;
@@ -242,7 +242,7 @@ u32 dat_dr_list(int max_to_return, int *
 		}
 
 		array = kmalloc(array_size * sizeof *array, GFP_ATOMIC);
-		if (NULL == array) {
+		if (!array) {
 			status =
 			    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
 				      DAT_RESOURCE_MEMORY);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_cookie.c linux-kernel-kmallc/dat-provider/dapl_cookie.c
--- linux-kernel-sizeof/dat-provider/dapl_cookie.c	2005-05-20 10:47:10.741014000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_cookie.c	2005-05-20 12:08:49.614000000 -0700
@@ -124,7 +124,7 @@ u32 dapl_cb_create(DAPL_COOKIE_BUFFER *b
 	size++;
 
 	buffer->pool = kmalloc(size * sizeof *buffer->pool, GFP_ATOMIC);
-	if (NULL != buffer->pool) {
+	if (buffer->pool) {
 		buffer->pool_size = size;
 		atomic_set(&buffer->head, 0);
 		atomic_set(&buffer->tail, 0);
@@ -135,9 +135,8 @@ u32 dapl_cb_create(DAPL_COOKIE_BUFFER *b
 		}
 
 		return DAT_SUCCESS;
-	} else {
+	} else
 		return DAT_INSUFFICIENT_RESOURCES;
-	}
 }
 
 /*
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_cr_util.c linux-kernel-kmallc/dat-provider/dapl_cr_util.c
--- linux-kernel-sizeof/dat-provider/dapl_cr_util.c	2005-05-20 09:39:00.781014000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_cr_util.c	2005-05-20 12:03:14.960015000 -0700
@@ -42,10 +42,9 @@ DAPL_CR *dapl_cr_alloc(DAPL_IA * ia_ptr)
 	DAPL_CR *cr_ptr;
 
 	/* Allocate EP */
-	cr_ptr = (DAPL_CR *) kmalloc(sizeof *cr_ptr, GFP_ATOMIC);
-	if (cr_ptr == NULL) {
+	cr_ptr = kmalloc(sizeof *cr_ptr, GFP_ATOMIC);
+	if (!cr_ptr)
 		return NULL;
-	}
 
 	/* zero the structure */
 	memset(cr_ptr, 0, sizeof *cr_ptr);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ep_connect.c linux-kernel-kmallc/dat-provider/dapl_ep_connect.c
--- linux-kernel-sizeof/dat-provider/dapl_ep_connect.c	2005-05-20 09:40:17.942011000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_ep_connect.c	2005-05-20 12:13:33.164001000 -0700
@@ -280,8 +280,13 @@ u32 dapl_ep_connect(DAT_EP_HANDLE ep_han
 		if (ep_ptr->param.ep_state == 
 			DAT_EP_STATE_ACTIVE_CONNECTION_PENDING
 		    && timeout != DAT_TIMEOUT_INFINITE) {
-			ep_ptr->cxn_timer = (DAPL_OS_TIMER *)
-			    kmalloc(sizeof *ep_ptr->cxn_timer, GFP_ATOMIC);
+			ep_ptr->cxn_timer = kmalloc(sizeof *ep_ptr->cxn_timer,
+						    GFP_ATOMIC);
+			if (!ep_ptr->cxn_timer) {
+				dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+						       DAT_RESOURCE_MEMORY);
+				goto bail;
+			}
 
 			dapl_timer_set(ep_ptr->cxn_timer,
 				       dapl_ep_timeout, ep_ptr, timeout);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ep_modify.c linux-kernel-kmallc/dat-provider/dapl_ep_modify.c
--- linux-kernel-sizeof/dat-provider/dapl_ep_modify.c	2005-05-20 10:08:28.558003000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_ep_modify.c	2005-05-20 12:14:07.358003000 -0700
@@ -386,7 +386,7 @@ u32 dapl_ep_modify(DAT_EP_HANDLE ep_hand
 	alloc_ep.send_iov_num = ep_attr1.max_request_iov;
 	alloc_ep.send_iov = kmalloc(ep_attr1.max_request_iov
 				    * sizeof *alloc_ep.send_iov, GFP_ATOMIC);
-	if (alloc_ep.recv_iov == NULL) {
+	if (!alloc_ep.recv_iov) {
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
@@ -396,7 +396,7 @@ u32 dapl_ep_modify(DAT_EP_HANDLE ep_hand
 	alloc_ep.recv_iov_num = ep_attr1.max_recv_iov;
 	alloc_ep.recv_iov = kmalloc(ep_attr1.max_recv_iov
 				    * sizeof *alloc_ep.recv_iov, GFP_ATOMIC);
-	if (alloc_ep.recv_iov == NULL) {
+	if (!alloc_ep.recv_iov) {
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ep_util.c linux-kernel-kmallc/dat-provider/dapl_ep_util.c
--- linux-kernel-sizeof/dat-provider/dapl_ep_util.c	2005-05-20 10:08:04.002013000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_ep_util.c	2005-05-20 12:15:02.171014000 -0700
@@ -60,9 +60,8 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
 	DAPL_EP *ep_ptr;
 
 	/* Allocate EP */
-	ep_ptr = (DAPL_EP *) kmalloc(sizeof *ep_ptr + sizeof (struct sockaddr), 
-				     GFP_ATOMIC);
-	if (ep_ptr == NULL)
+	ep_ptr = kmalloc(sizeof *ep_ptr + sizeof (struct sockaddr), GFP_ATOMIC);
+	if (!ep_ptr)
 		goto bail;
 
 	/* zero the structure */
@@ -126,8 +125,7 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
 
 	ep_ptr->recv_iov = kmalloc(ep_ptr->recv_iov_num * 
 				   sizeof *ep_ptr->recv_iov, GFP_ATOMIC);
-
-	if (NULL == ep_ptr->recv_iov) {
+	if (!ep_ptr->recv_iov) {
 		dapl_ep_dealloc(ep_ptr);
 		ep_ptr = NULL;
 		goto bail;
@@ -135,8 +133,7 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
 
 	ep_ptr->send_iov = kmalloc(ep_ptr->send_iov_num * 
 				   sizeof *ep_ptr->send_iov, GFP_ATOMIC);
-
-	if (NULL == ep_ptr->send_iov) {
+	if (!ep_ptr->send_iov) {
 		dapl_ep_dealloc(ep_ptr);
 		ep_ptr = NULL;
 		goto bail;
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_evd_util.c linux-kernel-kmallc/dat-provider/dapl_evd_util.c
--- linux-kernel-sizeof/dat-provider/dapl_evd_util.c	2005-05-20 09:42:44.127003000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_evd_util.c	2005-05-20 12:15:18.594000000 -0700
@@ -132,10 +132,9 @@ DAPL_EVD *dapl_evd_alloc(DAPL_IA * ia_pt
 	DAPL_EVD *evd_ptr;
 
 	/* Allocate EVD */
-	evd_ptr = (DAPL_EVD *) kmalloc(sizeof *evd_ptr, GFP_ATOMIC);
-	if (!evd_ptr) {
+	evd_ptr = kmalloc(sizeof *evd_ptr, GFP_ATOMIC);
+	if (!evd_ptr)
 		goto bail;
-	}
 
 	/* zero the structure */
 	memset(evd_ptr, 0, sizeof *evd_ptr);
@@ -178,10 +177,8 @@ u32 dapl_evd_event_alloc(DAPL_EVD *evd_p
 	u32 dat_status = DAT_SUCCESS;
 
 	/* Allocate EVENTs */
-	event_ptr =
-	    (struct dat_event *)kmalloc(evd_ptr->qlen * sizeof *event_ptr,
-					GFP_ATOMIC);
-	if (event_ptr == NULL) {
+	event_ptr = kmalloc(evd_ptr->qlen * sizeof *event_ptr, GFP_ATOMIC);
+	if (!event_ptr) {
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_hash.c linux-kernel-kmallc/dat-provider/dapl_hash.c
--- linux-kernel-sizeof/dat-provider/dapl_hash.c	2005-05-20 10:10:06.017003000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_hash.c	2005-05-20 12:15:55.837003000 -0700
@@ -213,8 +213,8 @@ dapl_hash_add(DAPL_HASH_TABLEP p_table, 
 		p_table->num_entries++;
 		status = TRUE;
 	} else {
-		DAPL_HASH_ELEM *newelement = (DAPL_HASH_ELEM *)
-		    kmalloc(sizeof *newelement, GFP_ATOMIC);
+		DAPL_HASH_ELEM *newelement = kmalloc(sizeof *newelement,
+						     GFP_ATOMIC);
 		/*
 		 * Add an element to the end of the chain
 		 */
@@ -232,10 +232,8 @@ dapl_hash_add(DAPL_HASH_TABLEP p_table, 
 			lastelement->next_element = newelement;
 			p_table->num_entries++;
 			status = TRUE;
-		} else {
-			/* allocation failed - should not happen */
+		} else
 			status = FALSE;
-		}
 	}
 
 	/*
@@ -332,7 +330,7 @@ u32 dapl_hash_create(int table_size, DAP
 
 	/* Allocate hash table */
 	p_table = kmalloc(sizeof *p_table, GFP_ATOMIC);
-	if (NULL == p_table) {
+	if (!p_table) {
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
@@ -341,8 +339,8 @@ u32 dapl_hash_create(int table_size, DAP
 	/* Init hash table, allocate and init and buckets */
 	memset(p_table, 0, sizeof *p_table);
 	p_table->tbl_size = table_size;
-	p_table->table = (DAPL_HASH_ELEM *) kmalloc(table_length, GFP_ATOMIC);
-	if (NULL == p_table->table) {
+	p_table->table = kmalloc(table_length, GFP_ATOMIC);
+	if (!p_table->table) {
 		kfree(p_table);
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_hca_util.c linux-kernel-kmallc/dat-provider/dapl_hca_util.c
--- linux-kernel-sizeof/dat-provider/dapl_hca_util.c	2005-05-20 09:44:53.376002000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_hca_util.c	2005-05-20 12:16:15.827004000 -0700
@@ -61,7 +61,7 @@ DAPL_HCA *dapl_hca_alloc(char *name, str
 	DAPL_HCA *hca_ptr;
 
 	hca_ptr = kmalloc(sizeof *hca_ptr, GFP_ATOMIC);
-	if (NULL != hca_ptr) {
+	if (hca_ptr) {
 		memset(hca_ptr, 0, sizeof *hca_ptr);
 
 		if (DAT_SUCCESS ==
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ia_util.c linux-kernel-kmallc/dat-provider/dapl_ia_util.c
--- linux-kernel-sizeof/dat-provider/dapl_ia_util.c	2005-05-20 09:45:22.314001000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_ia_util.c	2005-05-20 12:04:44.308003000 -0700
@@ -63,10 +63,9 @@ DAPL_IA *dapl_ia_alloc(struct dat_provid
 	DAPL_IA *ia_ptr;
 
 	/* Allocate IA */
-	ia_ptr = (DAPL_IA *) kmalloc(sizeof *ia_ptr, GFP_ATOMIC);
-	if (ia_ptr == NULL) {
+	ia_ptr = kmalloc(sizeof *ia_ptr, GFP_ATOMIC);
+	if (!ia_ptr)
 		return NULL;
-	}
 
 	/* zero the structure */
 	memset(ia_ptr, 0, sizeof *ia_ptr);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_lmr_util.c linux-kernel-kmallc/dat-provider/dapl_lmr_util.c
--- linux-kernel-sizeof/dat-provider/dapl_lmr_util.c	2005-05-20 09:45:43.253013000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_lmr_util.c	2005-05-20 12:05:02.135002000 -0700
@@ -48,10 +48,9 @@ DAPL_LMR *dapl_lmr_alloc(DAPL_IA * ia,
 	DAPL_LMR *lmr;
 
 	/* Allocate LMR */
-	lmr = (DAPL_LMR *) kmalloc(sizeof *lmr, GFP_ATOMIC);
-	if (NULL == lmr) {
+	lmr = kmalloc(sizeof *lmr, GFP_ATOMIC);
+	if (!lmr)
 		return NULL;
-	}
 
 	/* zero the structure */
 	memset(lmr, 0, sizeof *lmr);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_openib_util.c linux-kernel-kmallc/dat-provider/dapl_openib_util.c
--- linux-kernel-sizeof/dat-provider/dapl_openib_util.c	2005-05-20 10:02:29.919003000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_openib_util.c	2005-05-20 12:05:19.439003000 -0700
@@ -409,9 +409,8 @@ u32 dapl_ib_mr_register_physical(DAPL_IA
 	u64 *array;
 
 	array = (u64 *) phys_addr;
-	buf_list = (struct ib_phys_buf *) 
-		kmalloc(length * sizeof *buf_list, GFP_ATOMIC);
-	if (NULL == buf_list)
+	buf_list = kmalloc(length * sizeof *buf_list, GFP_ATOMIC);
+	if (!buf_list)
 		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
 				 DAT_RESOURCE_MEMORY);
 
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_provider.c linux-kernel-kmallc/dat-provider/dapl_provider.c
--- linux-kernel-sizeof/dat-provider/dapl_provider.c	2005-05-20 09:53:27.437003000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_provider.c	2005-05-20 12:06:06.106003000 -0700
@@ -151,7 +151,7 @@ u32 dapl_provider_list_create(void)
 	/* create the head node */
 	g_dapl_provider_list.head =
 	    kmalloc(sizeof *g_dapl_provider_list.head, GFP_ATOMIC);
-	if (NULL == g_dapl_provider_list.head) {
+	if (!g_dapl_provider_list.head) {
 		status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
@@ -162,7 +162,7 @@ u32 dapl_provider_list_create(void)
 	/* create the tail node */
 	g_dapl_provider_list.tail =
 	    kmalloc(sizeof *g_dapl_provider_list.tail, GFP_ATOMIC);
-	if (NULL == g_dapl_provider_list.tail) {
+	if (!g_dapl_provider_list.tail) {
 		status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
@@ -214,8 +214,7 @@ u32 dapl_provider_list_insert(const char
 	unsigned int len;
 
 	cur_node = kmalloc(sizeof *cur_node, GFP_ATOMIC);
-
-	if (NULL == cur_node) {
+	if (!cur_node) {
 		status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_pz_util.c linux-kernel-kmallc/dat-provider/dapl_pz_util.c
--- linux-kernel-sizeof/dat-provider/dapl_pz_util.c	2005-05-20 09:53:45.600010000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_pz_util.c	2005-05-20 12:06:18.950008000 -0700
@@ -57,10 +57,9 @@ DAPL_PZ *dapl_pz_alloc(DAPL_IA * ia)
 	DAPL_PZ *pz;
 
 	/* Allocate PZ */
-	pz = (DAPL_PZ *) kmalloc(sizeof *pz, GFP_ATOMIC);
-	if (NULL == pz) {
+	pz = kmalloc(sizeof *pz, GFP_ATOMIC);
+	if (!pz)
 		return NULL;
-	}
 
 	/* zero the structure */
 	memset(pz, 0, sizeof *pz);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ring_buffer_util.c linux-kernel-kmallc/dat-provider/dapl_ring_buffer_util.c
--- linux-kernel-sizeof/dat-provider/dapl_ring_buffer_util.c	2005-05-20 10:10:58.091013000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_ring_buffer_util.c	2005-05-20 12:06:48.434000000 -0700
@@ -72,14 +72,13 @@ u32 dapl_rbuf_alloc(DAPL_RING_BUFFER *rb
 		rsize <<= 1;
 	}
 
-	rbuf->base = (void *) kmalloc(rsize * sizeof *rbuf->base, GFP_ATOMIC);
-	if (rbuf->base != NULL) {
+	rbuf->base = kmalloc(rsize * sizeof *rbuf->base, GFP_ATOMIC);
+	if (rbuf->base) {
 		rbuf->lim = rsize - 1;
 		atomic_set(&rbuf->head, 0);
 		atomic_set(&rbuf->tail, 0);
-	} else {
+	} else
 		return DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
-	}
 
 	return DAT_SUCCESS;
 }
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_rmr_util.c linux-kernel-kmallc/dat-provider/dapl_rmr_util.c
--- linux-kernel-sizeof/dat-provider/dapl_rmr_util.c	2005-05-20 09:54:37.797008000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_rmr_util.c	2005-05-20 12:07:00.373015000 -0700
@@ -33,10 +33,9 @@ DAPL_RMR *dapl_rmr_alloc(DAPL_PZ * pz)
 	DAPL_RMR *rmr;
 
 	/* Allocate LMR */
-	rmr = (DAPL_RMR *) kmalloc(sizeof *rmr, GFP_ATOMIC);
-	if (NULL == rmr) {
+	rmr = kmalloc(sizeof *rmr, GFP_ATOMIC);
+	if (!rmr)
 		return NULL;
-	}
 
 	/* zero the structure */
 	memset(rmr, 0, sizeof *rmr);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_sp_util.c linux-kernel-kmallc/dat-provider/dapl_sp_util.c
--- linux-kernel-sizeof/dat-provider/dapl_sp_util.c	2005-05-20 09:54:54.673012000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_sp_util.c	2005-05-20 12:07:08.389004000 -0700
@@ -64,8 +64,8 @@ DAPL_SP *dapl_sp_alloc(DAPL_IA * ia_ptr,
 	DAPL_SP *sp_ptr;
 
 	/* Allocate EP */
-	sp_ptr = (DAPL_SP *) kmalloc(sizeof *sp_ptr, GFP_ATOMIC);
-	if (sp_ptr == NULL) 
+	sp_ptr = kmalloc(sizeof *sp_ptr, GFP_ATOMIC);
+	if (!sp_ptr) 
 		return NULL;
 
 	/* zero the structure */
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_srq_util.c linux-kernel-kmallc/dat-provider/dapl_srq_util.c
--- linux-kernel-sizeof/dat-provider/dapl_srq_util.c	2005-05-20 09:55:16.196002000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_srq_util.c	2005-05-20 12:07:15.455003000 -0700
@@ -59,11 +59,9 @@ DAPL_SRQ *dapl_srq_alloc(DAPL_IA * ia_pt
 	DAPL_SRQ *srq_ptr;
 
 	/* Allocate SRQ */
-	srq_ptr = (DAPL_SRQ *) kmalloc(sizeof *srq_ptr, GFP_ATOMIC);
-
-	if (srq_ptr == NULL) {
+	srq_ptr = kmalloc(sizeof *srq_ptr, GFP_ATOMIC);
+	if (!srq_ptr)
 		goto bail;
-	}
 
 	/* zero the structure */
 	memset(srq_ptr, 0, sizeof *srq_ptr);
diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_util.h linux-kernel-kmallc/dat-provider/dapl_util.h
--- linux-kernel-sizeof/dat-provider/dapl_util.h	2005-05-19 18:38:07.276001000 -0700
+++ linux-kernel-kmallc/dat-provider/dapl_util.h	2005-05-20 12:07:49.323013000 -0700
@@ -147,7 +147,7 @@ static __inline__ void *dapl_os_realloc(
 	void *newptr;
 
 	newptr = kmalloc(size, GFP_ATOMIC);
-	if (newptr != NULL) {
+	if (newptr) {
 		/* copy the mem array to the new */
 		memcpy(newptr, ptr, size);
 		kfree(ptr);
@@ -162,9 +162,8 @@ static __inline__ void *dapl_os_realloc(
 static __inline__ char *dapl_os_strdup(const char *str)
 {
 	char *ns = kmalloc(strlen(str) + 1, GFP_KERNEL);
-	if (ns) {
+	if (ns)
 		strcpy(ns, str);
-	}
 	return ns;
 }
 




More information about the general mailing list