[openib-general] [PATCHv2] kDAPL: kmalloc needs no cast

James Lentini jlentini at netapp.com
Fri May 20 15:47:07 PDT 2005


Committed in revision 2429.

On Fri, 20 May 2005, Tom Duffy wrote:

tduffy> This is a repost rebased off of r2427.
tduffy> 
tduffy> Please apply after my v2 of the sizeof patch.
tduffy> 
tduffy> Signed-off-by: Tom Duffy <tduffy at sun.com>
tduffy> 
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat/dictionary.c linux-kernel-kmalloc/dat/dictionary.c
tduffy> --- linux-kernel-sizeof/dat/dictionary.c	2005-05-20 09:55:56.230003000 -0700
tduffy> +++ linux-kernel-kmalloc/dat/dictionary.c	2005-05-20 15:19:47.778968000 -0700
tduffy> @@ -97,7 +97,7 @@ u32 dat_dictionary_entry_create(struct d
tduffy>  	BUG_ON(NULL == p_entry);
tduffy>  
tduffy>  	entry = kmalloc(sizeof *entry, GFP_ATOMIC);
tduffy> -	if (NULL == entry) {
tduffy> +	if (!entry) {
tduffy>  		status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat/dr.c linux-kernel-kmalloc/dat/dr.c
tduffy> --- linux-kernel-sizeof/dat/dr.c	2005-05-20 09:56:11.726007000 -0700
tduffy> +++ linux-kernel-kmalloc/dat/dr.c	2005-05-20 15:19:47.787972000 -0700
tduffy> @@ -85,7 +85,7 @@ u32 dat_dr_insert(const struct dat_provi
tduffy>  	u32 status;
tduffy>  
tduffy>  	data = kmalloc(sizeof *data, GFP_ATOMIC);
tduffy> -	if (NULL == data) {
tduffy> +	if (!data) {
tduffy>  		status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 
tduffy>  				   DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> @@ -242,7 +242,7 @@ u32 dat_dr_list(int max_to_return, int *
tduffy>  		}
tduffy>  
tduffy>  		array = kmalloc(array_size * sizeof *array, GFP_ATOMIC);
tduffy> -		if (NULL == array) {
tduffy> +		if (!array) {
tduffy>  			status =
tduffy>  			    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
tduffy>  				      DAT_RESOURCE_MEMORY);
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_cookie.c linux-kernel-kmalloc/dat-provider/dapl_cookie.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_cookie.c	2005-05-20 10:47:10.741014000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_cookie.c	2005-05-20 15:19:47.793960000 -0700
tduffy> @@ -124,7 +124,7 @@ u32 dapl_cb_create(DAPL_COOKIE_BUFFER *b
tduffy>  	size++;
tduffy>  
tduffy>  	buffer->pool = kmalloc(size * sizeof *buffer->pool, GFP_ATOMIC);
tduffy> -	if (NULL != buffer->pool) {
tduffy> +	if (buffer->pool) {
tduffy>  		buffer->pool_size = size;
tduffy>  		atomic_set(&buffer->head, 0);
tduffy>  		atomic_set(&buffer->tail, 0);
tduffy> @@ -135,9 +135,8 @@ u32 dapl_cb_create(DAPL_COOKIE_BUFFER *b
tduffy>  		}
tduffy>  
tduffy>  		return DAT_SUCCESS;
tduffy> -	} else {
tduffy> +	} else
tduffy>  		return DAT_INSUFFICIENT_RESOURCES;
tduffy> -	}
tduffy>  }
tduffy>  
tduffy>  /*
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_cr_util.c linux-kernel-kmalloc/dat-provider/dapl_cr_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_cr_util.c	2005-05-20 09:39:00.781014000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_cr_util.c	2005-05-20 15:19:47.797971000 -0700
tduffy> @@ -42,10 +42,9 @@ DAPL_CR *dapl_cr_alloc(DAPL_IA * ia_ptr)
tduffy>  	DAPL_CR *cr_ptr;
tduffy>  
tduffy>  	/* Allocate EP */
tduffy> -	cr_ptr = (DAPL_CR *) kmalloc(sizeof *cr_ptr, GFP_ATOMIC);
tduffy> -	if (cr_ptr == NULL) {
tduffy> +	cr_ptr = kmalloc(sizeof *cr_ptr, GFP_ATOMIC);
tduffy> +	if (!cr_ptr)
tduffy>  		return NULL;
tduffy> -	}
tduffy>  
tduffy>  	/* zero the structure */
tduffy>  	memset(cr_ptr, 0, sizeof *cr_ptr);
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ep_connect.c linux-kernel-kmalloc/dat-provider/dapl_ep_connect.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_ep_connect.c	2005-05-20 15:12:36.692972000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_ep_connect.c	2005-05-20 15:22:16.513960000 -0700
tduffy> @@ -280,8 +280,13 @@ u32 dapl_ep_connect(DAT_EP_HANDLE ep_han
tduffy>  		if (ep_ptr->param.ep_state == 
tduffy>  			DAT_EP_STATE_ACTIVE_CONNECTION_PENDING
tduffy>  		    && timeout != DAT_TIMEOUT_INFINITE) {
tduffy> -			ep_ptr->cxn_timer = (struct dapl_timer_entry *)
tduffy> -			    kmalloc(sizeof *ep_ptr->cxn_timer, GFP_ATOMIC);
tduffy> +			ep_ptr->cxn_timer = kmalloc(sizeof *ep_ptr->cxn_timer,
tduffy> +						    GFP_ATOMIC);
tduffy> +			if (!ep_ptr->cxn_timer) {
tduffy> +				dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
tduffy> +						       DAT_RESOURCE_MEMORY);
tduffy> +				goto bail;
tduffy> +			}
tduffy>  
tduffy>  			dapl_timer_set(ep_ptr->cxn_timer,
tduffy>  				       dapl_ep_timeout, ep_ptr, timeout);
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ep_modify.c linux-kernel-kmalloc/dat-provider/dapl_ep_modify.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_ep_modify.c	2005-05-20 15:13:44.645961000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_ep_modify.c	2005-05-20 15:19:47.835961000 -0700
tduffy> @@ -386,7 +386,7 @@ u32 dapl_ep_modify(DAT_EP_HANDLE ep_hand
tduffy>  	alloc_ep.send_iov_num = ep_attr1.max_request_iov;
tduffy>  	alloc_ep.send_iov = kmalloc(ep_attr1.max_request_iov
tduffy>  				    * sizeof *alloc_ep.send_iov, GFP_ATOMIC);
tduffy> -	if (alloc_ep.recv_iov == NULL) {
tduffy> +	if (!alloc_ep.recv_iov) {
tduffy>  		dat_status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> @@ -396,7 +396,7 @@ u32 dapl_ep_modify(DAT_EP_HANDLE ep_hand
tduffy>  	alloc_ep.recv_iov_num = ep_attr1.max_recv_iov;
tduffy>  	alloc_ep.recv_iov = kmalloc(ep_attr1.max_recv_iov
tduffy>  				    * sizeof *alloc_ep.recv_iov, GFP_ATOMIC);
tduffy> -	if (alloc_ep.recv_iov == NULL) {
tduffy> +	if (!alloc_ep.recv_iov) {
tduffy>  		dat_status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ep_util.c linux-kernel-kmalloc/dat-provider/dapl_ep_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_ep_util.c	2005-05-20 15:14:06.429964000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_ep_util.c	2005-05-20 15:19:47.840972000 -0700
tduffy> @@ -60,9 +60,8 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
tduffy>  	DAPL_EP *ep_ptr;
tduffy>  
tduffy>  	/* Allocate EP */
tduffy> -	ep_ptr = (DAPL_EP *) kmalloc(sizeof *ep_ptr + sizeof (struct sockaddr), 
tduffy> -				     GFP_ATOMIC);
tduffy> -	if (ep_ptr == NULL)
tduffy> +	ep_ptr = kmalloc(sizeof *ep_ptr + sizeof (struct sockaddr), GFP_ATOMIC);
tduffy> +	if (!ep_ptr)
tduffy>  		goto bail;
tduffy>  
tduffy>  	/* zero the structure */
tduffy> @@ -126,8 +125,7 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
tduffy>  
tduffy>  	ep_ptr->recv_iov = kmalloc(ep_ptr->recv_iov_num * 
tduffy>  				   sizeof *ep_ptr->recv_iov, GFP_ATOMIC);
tduffy> -
tduffy> -	if (NULL == ep_ptr->recv_iov) {
tduffy> +	if (!ep_ptr->recv_iov) {
tduffy>  		dapl_ep_dealloc(ep_ptr);
tduffy>  		ep_ptr = NULL;
tduffy>  		goto bail;
tduffy> @@ -135,8 +133,7 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
tduffy>  
tduffy>  	ep_ptr->send_iov = kmalloc(ep_ptr->send_iov_num * 
tduffy>  				   sizeof *ep_ptr->send_iov, GFP_ATOMIC);
tduffy> -
tduffy> -	if (NULL == ep_ptr->send_iov) {
tduffy> +	if (!ep_ptr->send_iov) {
tduffy>  		dapl_ep_dealloc(ep_ptr);
tduffy>  		ep_ptr = NULL;
tduffy>  		goto bail;
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_evd_util.c linux-kernel-kmalloc/dat-provider/dapl_evd_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_evd_util.c	2005-05-20 15:15:32.618966000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_evd_util.c	2005-05-20 15:19:47.867963000 -0700
tduffy> @@ -123,10 +123,9 @@ DAPL_EVD *dapl_evd_alloc(DAPL_IA * ia_pt
tduffy>  	DAPL_EVD *evd_ptr;
tduffy>  
tduffy>  	/* Allocate EVD */
tduffy> -	evd_ptr = (DAPL_EVD *) kmalloc(sizeof *evd_ptr, GFP_ATOMIC);
tduffy> -	if (!evd_ptr) {
tduffy> +	evd_ptr = kmalloc(sizeof *evd_ptr, GFP_ATOMIC);
tduffy> +	if (!evd_ptr)
tduffy>  		goto bail;
tduffy> -	}
tduffy>  
tduffy>  	/* zero the structure */
tduffy>  	memset(evd_ptr, 0, sizeof *evd_ptr);
tduffy> @@ -169,10 +168,8 @@ u32 dapl_evd_event_alloc(DAPL_EVD *evd_p
tduffy>  	u32 dat_status = DAT_SUCCESS;
tduffy>  
tduffy>  	/* Allocate EVENTs */
tduffy> -	event_ptr =
tduffy> -	    (struct dat_event *)kmalloc(evd_ptr->qlen * sizeof *event_ptr,
tduffy> -					GFP_ATOMIC);
tduffy> -	if (event_ptr == NULL) {
tduffy> +	event_ptr = kmalloc(evd_ptr->qlen * sizeof *event_ptr, GFP_ATOMIC);
tduffy> +	if (!event_ptr) {
tduffy>  		dat_status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_hash.c linux-kernel-kmalloc/dat-provider/dapl_hash.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_hash.c	2005-05-20 10:10:06.017003000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_hash.c	2005-05-20 15:19:47.873960000 -0700
tduffy> @@ -213,8 +213,8 @@ dapl_hash_add(DAPL_HASH_TABLEP p_table, 
tduffy>  		p_table->num_entries++;
tduffy>  		status = TRUE;
tduffy>  	} else {
tduffy> -		DAPL_HASH_ELEM *newelement = (DAPL_HASH_ELEM *)
tduffy> -		    kmalloc(sizeof *newelement, GFP_ATOMIC);
tduffy> +		DAPL_HASH_ELEM *newelement = kmalloc(sizeof *newelement,
tduffy> +						     GFP_ATOMIC);
tduffy>  		/*
tduffy>  		 * Add an element to the end of the chain
tduffy>  		 */
tduffy> @@ -232,10 +232,8 @@ dapl_hash_add(DAPL_HASH_TABLEP p_table, 
tduffy>  			lastelement->next_element = newelement;
tduffy>  			p_table->num_entries++;
tduffy>  			status = TRUE;
tduffy> -		} else {
tduffy> -			/* allocation failed - should not happen */
tduffy> +		} else
tduffy>  			status = FALSE;
tduffy> -		}
tduffy>  	}
tduffy>  
tduffy>  	/*
tduffy> @@ -332,7 +330,7 @@ u32 dapl_hash_create(int table_size, DAP
tduffy>  
tduffy>  	/* Allocate hash table */
tduffy>  	p_table = kmalloc(sizeof *p_table, GFP_ATOMIC);
tduffy> -	if (NULL == p_table) {
tduffy> +	if (!p_table) {
tduffy>  		dat_status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> @@ -341,8 +339,8 @@ u32 dapl_hash_create(int table_size, DAP
tduffy>  	/* Init hash table, allocate and init and buckets */
tduffy>  	memset(p_table, 0, sizeof *p_table);
tduffy>  	p_table->tbl_size = table_size;
tduffy> -	p_table->table = (DAPL_HASH_ELEM *) kmalloc(table_length, GFP_ATOMIC);
tduffy> -	if (NULL == p_table->table) {
tduffy> +	p_table->table = kmalloc(table_length, GFP_ATOMIC);
tduffy> +	if (!p_table->table) {
tduffy>  		kfree(p_table);
tduffy>  		dat_status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_hca_util.c linux-kernel-kmalloc/dat-provider/dapl_hca_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_hca_util.c	2005-05-20 15:11:31.050974000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_hca_util.c	2005-05-20 15:19:47.878970000 -0700
tduffy> @@ -61,7 +61,7 @@ DAPL_HCA *dapl_hca_alloc(char *name, str
tduffy>  	DAPL_HCA *hca_ptr;
tduffy>  
tduffy>  	hca_ptr = kmalloc(sizeof *hca_ptr, GFP_ATOMIC);
tduffy> -	if (NULL != hca_ptr) {
tduffy> +	if (hca_ptr) {
tduffy>  		memset(hca_ptr, 0, sizeof *hca_ptr);
tduffy>  
tduffy>  		if (DAT_SUCCESS ==
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ia_util.c linux-kernel-kmalloc/dat-provider/dapl_ia_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_ia_util.c	2005-05-20 15:11:31.438968000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_ia_util.c	2005-05-20 15:19:47.884961000 -0700
tduffy> @@ -63,10 +63,9 @@ DAPL_IA *dapl_ia_alloc(struct dat_provid
tduffy>  	DAPL_IA *ia_ptr;
tduffy>  
tduffy>  	/* Allocate IA */
tduffy> -	ia_ptr = (DAPL_IA *) kmalloc(sizeof *ia_ptr, GFP_ATOMIC);
tduffy> -	if (ia_ptr == NULL) {
tduffy> +	ia_ptr = kmalloc(sizeof *ia_ptr, GFP_ATOMIC);
tduffy> +	if (!ia_ptr)
tduffy>  		return NULL;
tduffy> -	}
tduffy>  
tduffy>  	/* zero the structure */
tduffy>  	memset(ia_ptr, 0, sizeof *ia_ptr);
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_lmr_util.c linux-kernel-kmalloc/dat-provider/dapl_lmr_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_lmr_util.c	2005-05-20 09:45:43.253013000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_lmr_util.c	2005-05-20 15:19:47.890970000 -0700
tduffy> @@ -48,10 +48,9 @@ DAPL_LMR *dapl_lmr_alloc(DAPL_IA * ia,
tduffy>  	DAPL_LMR *lmr;
tduffy>  
tduffy>  	/* Allocate LMR */
tduffy> -	lmr = (DAPL_LMR *) kmalloc(sizeof *lmr, GFP_ATOMIC);
tduffy> -	if (NULL == lmr) {
tduffy> +	lmr = kmalloc(sizeof *lmr, GFP_ATOMIC);
tduffy> +	if (!lmr)
tduffy>  		return NULL;
tduffy> -	}
tduffy>  
tduffy>  	/* zero the structure */
tduffy>  	memset(lmr, 0, sizeof *lmr);
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_openib_util.c linux-kernel-kmalloc/dat-provider/dapl_openib_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_openib_util.c	2005-05-20 15:11:31.746962000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_openib_util.c	2005-05-20 15:19:47.920964000 -0700
tduffy> @@ -408,9 +408,8 @@ u32 dapl_ib_mr_register_physical(DAPL_IA
tduffy>  	u64 *array;
tduffy>  
tduffy>  	array = (u64 *) phys_addr;
tduffy> -	buf_list = (struct ib_phys_buf *) 
tduffy> -		kmalloc(length * sizeof *buf_list, GFP_ATOMIC);
tduffy> -	if (NULL == buf_list)
tduffy> +	buf_list = kmalloc(length * sizeof *buf_list, GFP_ATOMIC);
tduffy> +	if (!buf_list)
tduffy>  		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
tduffy>  				 DAT_RESOURCE_MEMORY);
tduffy>  
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_provider.c linux-kernel-kmalloc/dat-provider/dapl_provider.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_provider.c	2005-05-20 09:53:27.437003000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_provider.c	2005-05-20 15:19:47.926965000 -0700
tduffy> @@ -151,7 +151,7 @@ u32 dapl_provider_list_create(void)
tduffy>  	/* create the head node */
tduffy>  	g_dapl_provider_list.head =
tduffy>  	    kmalloc(sizeof *g_dapl_provider_list.head, GFP_ATOMIC);
tduffy> -	if (NULL == g_dapl_provider_list.head) {
tduffy> +	if (!g_dapl_provider_list.head) {
tduffy>  		status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> @@ -162,7 +162,7 @@ u32 dapl_provider_list_create(void)
tduffy>  	/* create the tail node */
tduffy>  	g_dapl_provider_list.tail =
tduffy>  	    kmalloc(sizeof *g_dapl_provider_list.tail, GFP_ATOMIC);
tduffy> -	if (NULL == g_dapl_provider_list.tail) {
tduffy> +	if (!g_dapl_provider_list.tail) {
tduffy>  		status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> @@ -214,8 +214,7 @@ u32 dapl_provider_list_insert(const char
tduffy>  	unsigned int len;
tduffy>  
tduffy>  	cur_node = kmalloc(sizeof *cur_node, GFP_ATOMIC);
tduffy> -
tduffy> -	if (NULL == cur_node) {
tduffy> +	if (!cur_node) {
tduffy>  		status =
tduffy>  		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy>  		goto bail;
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_pz_util.c linux-kernel-kmalloc/dat-provider/dapl_pz_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_pz_util.c	2005-05-20 15:11:31.492027000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_pz_util.c	2005-05-20 15:23:13.954961000 -0700
tduffy> @@ -57,8 +57,8 @@ DAPL_PZ *dapl_pz_alloc(DAPL_IA * ia)
tduffy>  	DAPL_PZ *pz;
tduffy>  
tduffy>  	/* Allocate PZ */
tduffy> -	pz = (DAPL_PZ *) kmalloc(sizeof *pz, GFP_ATOMIC);
tduffy> -	if (NULL == pz) 
tduffy> +	pz = kmalloc(sizeof *pz, GFP_ATOMIC);
tduffy> +	if (!pz) 
tduffy>  		return NULL;
tduffy>  
tduffy>  	/* zero the structure */
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_ring_buffer_util.c linux-kernel-kmalloc/dat-provider/dapl_ring_buffer_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_ring_buffer_util.c	2005-05-20 15:11:30.864961000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_ring_buffer_util.c	2005-05-20 15:19:47.959972000 -0700
tduffy> @@ -72,14 +72,13 @@ u32 dapl_rbuf_alloc(DAPL_RING_BUFFER *rb
tduffy>  		rsize <<= 1;
tduffy>  	}
tduffy>  
tduffy> -	rbuf->base = (void *) kmalloc(rsize * sizeof *rbuf->base, GFP_ATOMIC);
tduffy> -	if (rbuf->base != NULL) {
tduffy> +	rbuf->base = kmalloc(rsize * sizeof *rbuf->base, GFP_ATOMIC);
tduffy> +	if (rbuf->base) {
tduffy>  		rbuf->lim = rsize - 1;
tduffy>  		atomic_set(&rbuf->head, 0);
tduffy>  		atomic_set(&rbuf->tail, 0);
tduffy> -	} else {
tduffy> +	} else
tduffy>  		return DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
tduffy> -	}
tduffy>  
tduffy>  	return DAT_SUCCESS;
tduffy>  }
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_rmr_util.c linux-kernel-kmalloc/dat-provider/dapl_rmr_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_rmr_util.c	2005-05-20 09:54:37.797008000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_rmr_util.c	2005-05-20 15:19:47.964962000 -0700
tduffy> @@ -33,10 +33,9 @@ DAPL_RMR *dapl_rmr_alloc(DAPL_PZ * pz)
tduffy>  	DAPL_RMR *rmr;
tduffy>  
tduffy>  	/* Allocate LMR */
tduffy> -	rmr = (DAPL_RMR *) kmalloc(sizeof *rmr, GFP_ATOMIC);
tduffy> -	if (NULL == rmr) {
tduffy> +	rmr = kmalloc(sizeof *rmr, GFP_ATOMIC);
tduffy> +	if (!rmr)
tduffy>  		return NULL;
tduffy> -	}
tduffy>  
tduffy>  	/* zero the structure */
tduffy>  	memset(rmr, 0, sizeof *rmr);
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_sp_util.c linux-kernel-kmalloc/dat-provider/dapl_sp_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_sp_util.c	2005-05-20 15:11:32.615964000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_sp_util.c	2005-05-20 15:19:47.969972000 -0700
tduffy> @@ -64,8 +64,8 @@ DAPL_SP *dapl_sp_alloc(DAPL_IA * ia_ptr,
tduffy>  	DAPL_SP *sp_ptr;
tduffy>  
tduffy>  	/* Allocate EP */
tduffy> -	sp_ptr = (DAPL_SP *) kmalloc(sizeof *sp_ptr, GFP_ATOMIC);
tduffy> -	if (sp_ptr == NULL) 
tduffy> +	sp_ptr = kmalloc(sizeof *sp_ptr, GFP_ATOMIC);
tduffy> +	if (!sp_ptr) 
tduffy>  		return NULL;
tduffy>  
tduffy>  	/* zero the structure */
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_srq_util.c linux-kernel-kmalloc/dat-provider/dapl_srq_util.c
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_srq_util.c	2005-05-20 09:55:16.196002000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_srq_util.c	2005-05-20 15:19:47.973961000 -0700
tduffy> @@ -59,11 +59,9 @@ DAPL_SRQ *dapl_srq_alloc(DAPL_IA * ia_pt
tduffy>  	DAPL_SRQ *srq_ptr;
tduffy>  
tduffy>  	/* Allocate SRQ */
tduffy> -	srq_ptr = (DAPL_SRQ *) kmalloc(sizeof *srq_ptr, GFP_ATOMIC);
tduffy> -
tduffy> -	if (srq_ptr == NULL) {
tduffy> +	srq_ptr = kmalloc(sizeof *srq_ptr, GFP_ATOMIC);
tduffy> +	if (!srq_ptr)
tduffy>  		goto bail;
tduffy> -	}
tduffy>  
tduffy>  	/* zero the structure */
tduffy>  	memset(srq_ptr, 0, sizeof *srq_ptr);
tduffy> diff -Nurp -X /home/tduffy/dontdiff linux-kernel-sizeof/dat-provider/dapl_util.h linux-kernel-kmalloc/dat-provider/dapl_util.h
tduffy> --- linux-kernel-sizeof/dat-provider/dapl_util.h	2005-05-20 15:11:32.661977000 -0700
tduffy> +++ linux-kernel-kmalloc/dat-provider/dapl_util.h	2005-05-20 15:19:47.999965000 -0700
tduffy> @@ -144,7 +144,7 @@ static inline void *dapl_os_realloc(void
tduffy>  	void *newptr;
tduffy>  
tduffy>  	newptr = kmalloc(size, GFP_ATOMIC);
tduffy> -	if (newptr != NULL) {
tduffy> +	if (newptr) {
tduffy>  		/* copy the mem array to the new */
tduffy>  		memcpy(newptr, ptr, size);
tduffy>  		kfree(ptr);
tduffy> @@ -159,9 +159,8 @@ static inline void *dapl_os_realloc(void
tduffy>  static inline char *dapl_os_strdup(const char *str)
tduffy>  {
tduffy>  	char *ns = kmalloc(strlen(str) + 1, GFP_KERNEL);
tduffy> -	if (ns) {
tduffy> +	if (ns)
tduffy>  		strcpy(ns, str);
tduffy> -	}
tduffy>  	return ns;
tduffy>  }
tduffy>  
tduffy> 



More information about the general mailing list