[openib-general] [PATCH] kDAPL & at: sizeof is not a function

Tom Duffy tduffy at sun.com
Fri May 20 10:51:19 PDT 2005


sizeof is not a function.  Also it is generally better to take the
sizeof the actual object your are memcpy()ing or kmalloc()ing in case
the type changes.

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

Index: linux-kernel-sizeof/dat-provider/dapl_cookie.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_cookie.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_cookie.c	(working copy)
@@ -123,7 +123,7 @@ u32 dapl_cb_create(DAPL_COOKIE_BUFFER *b
 	 */
 	size++;
 
-	buffer->pool = kmalloc(size * sizeof(DAPL_COOKIE), GFP_ATOMIC);
+	buffer->pool = kmalloc(size * sizeof *buffer->pool, GFP_ATOMIC);
 	if (NULL != buffer->pool) {
 		buffer->pool_size = size;
 		atomic_set(&buffer->head, 0);
Index: linux-kernel-sizeof/dat-provider/dapl_ep_connect.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_ep_connect.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_ep_connect.c	(working copy)
@@ -281,7 +281,7 @@ u32 dapl_ep_connect(DAT_EP_HANDLE ep_han
 			DAT_EP_STATE_ACTIVE_CONNECTION_PENDING
 		    && timeout != DAT_TIMEOUT_INFINITE) {
 			ep_ptr->cxn_timer = (DAPL_OS_TIMER *)
-			    kmalloc(sizeof(DAPL_OS_TIMER), GFP_ATOMIC);
+			    kmalloc(sizeof *ep_ptr->cxn_timer, GFP_ATOMIC);
 
 			dapl_timer_set(ep_ptr->cxn_timer,
 				       dapl_ep_timeout, ep_ptr, timeout);
Index: linux-kernel-sizeof/dat-provider/dapl_ring_buffer_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_ring_buffer_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_ring_buffer_util.c	(working copy)
@@ -72,7 +72,7 @@ u32 dapl_rbuf_alloc(DAPL_RING_BUFFER *rb
 		rsize <<= 1;
 	}
 
-	rbuf->base = (void *) kmalloc(rsize * sizeof(void *), GFP_ATOMIC);
+	rbuf->base = (void *) kmalloc(rsize * sizeof *rbuf->base, GFP_ATOMIC);
 	if (rbuf->base != NULL) {
 		rbuf->lim = rsize - 1;
 		atomic_set(&rbuf->head, 0);
Index: linux-kernel-sizeof/dat-provider/dapl_lmr_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_lmr_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_lmr_util.c	(working copy)
@@ -48,13 +48,13 @@ DAPL_LMR *dapl_lmr_alloc(DAPL_IA * ia,
 	DAPL_LMR *lmr;
 
 	/* Allocate LMR */
-	lmr = (DAPL_LMR *) kmalloc(sizeof(DAPL_LMR), GFP_ATOMIC);
+	lmr = (DAPL_LMR *) kmalloc(sizeof *lmr, GFP_ATOMIC);
 	if (NULL == lmr) {
 		return NULL;
 	}
 
 	/* zero the structure */
-	memset(lmr, 0, sizeof(DAPL_LMR));
+	memset(lmr, 0, sizeof *lmr);
 
 	/*
 	 * initialize the header
Index: linux-kernel-sizeof/dat-provider/dapl_hca_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_hca_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_hca_util.c	(working copy)
@@ -60,9 +60,9 @@ DAPL_HCA *dapl_hca_alloc(char *name, str
 {
 	DAPL_HCA *hca_ptr;
 
-	hca_ptr = kmalloc(sizeof(DAPL_HCA), GFP_ATOMIC);
+	hca_ptr = kmalloc(sizeof *hca_ptr, GFP_ATOMIC);
 	if (NULL != hca_ptr) {
-		memset(hca_ptr, 0, sizeof(DAPL_HCA));
+		memset(hca_ptr, 0, sizeof *hca_ptr);
 
 		if (DAT_SUCCESS ==
 		    dapl_hash_create(DAPL_HASH_TABLE_DEFAULT_CAPACITY,
Index: linux-kernel-sizeof/dat-provider/dapl_cr_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_cr_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_cr_util.c	(working copy)
@@ -42,13 +42,13 @@ DAPL_CR *dapl_cr_alloc(DAPL_IA * ia_ptr)
 	DAPL_CR *cr_ptr;
 
 	/* Allocate EP */
-	cr_ptr = (DAPL_CR *) kmalloc(sizeof(DAPL_CR), GFP_ATOMIC);
+	cr_ptr = (DAPL_CR *) kmalloc(sizeof *cr_ptr, GFP_ATOMIC);
 	if (cr_ptr == NULL) {
 		return NULL;
 	}
 
 	/* zero the structure */
-	memset(cr_ptr, 0, sizeof(DAPL_CR));
+	memset(cr_ptr, 0, sizeof *cr_ptr);
 
 	/*
 	 * initialize the header
Index: linux-kernel-sizeof/dat-provider/dapl_srq_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_srq_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_srq_util.c	(working copy)
@@ -59,14 +59,14 @@ DAPL_SRQ *dapl_srq_alloc(DAPL_IA * ia_pt
 	DAPL_SRQ *srq_ptr;
 
 	/* Allocate SRQ */
-	srq_ptr = (DAPL_SRQ *) kmalloc(sizeof(DAPL_SRQ), GFP_ATOMIC);
+	srq_ptr = (DAPL_SRQ *) kmalloc(sizeof *srq_ptr, GFP_ATOMIC);
 
 	if (srq_ptr == NULL) {
 		goto bail;
 	}
 
 	/* zero the structure */
-	memset(srq_ptr, 0, sizeof(DAPL_SRQ));
+	memset(srq_ptr, 0, sizeof *srq_ptr);
 
 	/*
 	 * initialize the header
Index: linux-kernel-sizeof/dat-provider/dapl_pz_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_pz_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_pz_util.c	(working copy)
@@ -57,13 +57,13 @@ DAPL_PZ *dapl_pz_alloc(DAPL_IA * ia)
 	DAPL_PZ *pz;
 
 	/* Allocate PZ */
-	pz = (DAPL_PZ *) kmalloc(sizeof(DAPL_PZ), GFP_ATOMIC);
+	pz = (DAPL_PZ *) kmalloc(sizeof *pz, GFP_ATOMIC);
 	if (NULL == pz) {
 		return NULL;
 	}
 
 	/* zero the structure */
-	memset(pz, 0, sizeof(DAPL_PZ));
+	memset(pz, 0, sizeof *pz);
 
 	/*
 	 * initialize the header
Index: linux-kernel-sizeof/dat-provider/dapl_ia_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_ia_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_ia_util.c	(working copy)
@@ -63,13 +63,13 @@ DAPL_IA *dapl_ia_alloc(struct dat_provid
 	DAPL_IA *ia_ptr;
 
 	/* Allocate IA */
-	ia_ptr = (DAPL_IA *) kmalloc(sizeof(DAPL_IA), GFP_ATOMIC);
+	ia_ptr = (DAPL_IA *) kmalloc(sizeof *ia_ptr, GFP_ATOMIC);
 	if (ia_ptr == NULL) {
 		return NULL;
 	}
 
 	/* zero the structure */
-	memset(ia_ptr, 0, sizeof(DAPL_IA));
+	memset(ia_ptr, 0, sizeof *ia_ptr);
 
 	/*
 	 * initialize the header
Index: linux-kernel-sizeof/dat-provider/dapl_provider.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_provider.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_provider.c	(working copy)
@@ -150,27 +150,25 @@ u32 dapl_provider_list_create(void)
 
 	/* create the head node */
 	g_dapl_provider_list.head =
-	    kmalloc(sizeof(DAPL_PROVIDER_LIST_NODE), GFP_ATOMIC);
+	    kmalloc(sizeof *g_dapl_provider_list.head, GFP_ATOMIC);
 	if (NULL == g_dapl_provider_list.head) {
 		status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
 	}
 
-	memset(g_dapl_provider_list.head, 0,
-			sizeof(DAPL_PROVIDER_LIST_NODE));
+	memset(g_dapl_provider_list.head, 0, sizeof *g_dapl_provider_list.head);
 
 	/* create the tail node */
 	g_dapl_provider_list.tail =
-	    kmalloc(sizeof(DAPL_PROVIDER_LIST_NODE), GFP_ATOMIC);
+	    kmalloc(sizeof *g_dapl_provider_list.tail, GFP_ATOMIC);
 	if (NULL == g_dapl_provider_list.tail) {
 		status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 		goto bail;
 	}
 
-	memset(g_dapl_provider_list.tail, 0, 
-			sizeof(DAPL_PROVIDER_LIST_NODE));
+	memset(g_dapl_provider_list.tail, 0, sizeof *g_dapl_provider_list.tail);
 
 	g_dapl_provider_list.head->next = g_dapl_provider_list.tail;
 	g_dapl_provider_list.tail->prev = g_dapl_provider_list.head;
@@ -215,7 +213,7 @@ u32 dapl_provider_list_insert(const char
 	u32 status = DAT_SUCCESS;
 	unsigned int len;
 
-	cur_node = kmalloc(sizeof(DAPL_PROVIDER_LIST_NODE), GFP_ATOMIC);
+	cur_node = kmalloc(sizeof *cur_node, GFP_ATOMIC);
 
 	if (NULL == cur_node) {
 		status =
Index: linux-kernel-sizeof/dat-provider/dapl_openib_cm.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_openib_cm.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_openib_cm.c	(working copy)
@@ -427,7 +427,7 @@ u32 dapl_ib_connect(DAT_EP_HANDLE ep_han
 	ia_ptr = conn->ep->header.owner_ia;
 
 	/* Setup QP/CM parameters */
-	memset(&conn->param, 0, sizeof(conn->param));
+	memset(&conn->param, 0, sizeof conn->param);
 	conn->param.qp_type = IB_QPT_RC;
 	conn->param.qp_num = conn->ep->qp_handle->qp_num;
 	conn->param.private_data = private_data;
@@ -441,7 +441,7 @@ u32 dapl_ib_connect(DAT_EP_HANDLE ep_han
 	conn->param.local_cm_response_timeout = DAPL_OPENIB_CM_RESPONSE_TIMEOUT;
 	conn->param.max_cm_retries = DAPL_OPENIB_MAX_CM_RETRIES;
 
-	memcpy(&conn->service_id, &remote_conn_qual, sizeof(u64));
+	memcpy(&conn->service_id, &remote_conn_qual, sizeof conn->service_id);
 
 	conn->remote_ia_address = remote_ia_address;
 	conn->dapl_comp.fn = &dapl_rt_comp_handler;
@@ -771,7 +771,7 @@ u32 dapl_ib_accept_connection(DAT_CR_HAN
 	ep_ptr->cm_handle = conn;
 	conn->ep = ep_ptr;
 
-	memset(&passive_params, 0, sizeof(passive_params));
+	memset(&passive_params, 0, sizeof passive_params);
 	passive_params.private_data = prd_ptr;
 	passive_params.private_data_len = private_data_size;
 	passive_params.qp_num = ep_ptr->qp_handle->qp_num;
@@ -848,7 +848,7 @@ u32 dapl_ib_cm_remote_addr(DAT_HANDLE da
 
 	if (!memcmp(&ia_ptr->hca_ptr->ib_trans.gid, &remote_gid, 16)) {
 		memcpy(remote_ia_address, &ia_ptr->hca_ptr->hca_address,
-		       sizeof(struct sockaddr));
+		       sizeof *remote_ia_address);
 		return DAT_SUCCESS;
 	}
 
Index: linux-kernel-sizeof/dat-provider/dapl_openib_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_openib_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_openib_util.c	(working copy)
@@ -164,7 +164,7 @@ u32 dapl_ib_open_hca(char *name, DAPL_HC
 {
 	u32 dat_ret;
 
-	memset(&hca_ptr->ib_trans.gid.global, 0, sizeof(union ib_gid));
+	memset(&hca_ptr->ib_trans.gid.global, 0, sizeof hca_ptr->ib_trans.gid);
 	hca_ptr->ib_trans.lid = 0;
 
 	dat_ret = dapl_ib_get_hca_ids(hca_ptr->ib_hca_handle,
@@ -410,7 +410,7 @@ u32 dapl_ib_mr_register_physical(DAPL_IA
 
 	array = (u64 *) phys_addr;
 	buf_list = (struct ib_phys_buf *) 
-		kmalloc(length * sizeof(struct ib_phys_buf), GFP_ATOMIC);
+		kmalloc(length * sizeof *buf_list, GFP_ATOMIC);
 	if (NULL == buf_list)
 		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
 				 DAT_RESOURCE_MEMORY);
Index: linux-kernel-sizeof/dat-provider/dapl_ep_modify.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_ep_modify.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_ep_modify.c	(working copy)
@@ -385,8 +385,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(ib_data_segment_t), 
-				    GFP_ATOMIC);
+				    * sizeof *alloc_ep.send_iov, GFP_ATOMIC);
 	if (alloc_ep.recv_iov == NULL) {
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
@@ -396,8 +395,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(ib_data_segment_t), 
-				    GFP_ATOMIC);
+				    * sizeof *alloc_ep.recv_iov, GFP_ATOMIC);
 	if (alloc_ep.recv_iov == NULL) {
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
Index: linux-kernel-sizeof/dat-provider/dapl_openib_qp.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_openib_qp.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_openib_qp.c	(working copy)
@@ -305,7 +305,7 @@ int dapl_modify_qp_state_to_init(ib_qp_h
 	int qp_attr_mask;
 	int ib_status;
 
-	memset(&qp_attr, 0, sizeof(qp_attr));
+	memset(&qp_attr, 0, sizeof qp_attr);
 	qp_attr.qp_state = IB_QPS_INIT;
 	qp_attr_mask = IB_QP_STATE;
 	qp_attr.qp_access_flags =
@@ -328,7 +328,7 @@ int dapl_modify_qp_state_to_error(ib_qp_
 	int qp_attr_mask;
 	int ib_status;
 
-	memset(&qp_attr, 0, sizeof(qp_attr));
+	memset(&qp_attr, 0, sizeof qp_attr);
 	qp_attr.qp_state = IB_QPS_ERR;
 	qp_attr_mask = IB_QP_STATE;
 	ib_status = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
@@ -342,7 +342,7 @@ int dapl_modify_qp_state_to_reset(ib_qp_
 	int qp_attr_mask;
 	int ib_status;
 
-	memset(&qp_attr, 0, sizeof(qp_attr));
+	memset(&qp_attr, 0, sizeof qp_attr);
 	qp_attr.qp_state = IB_QPS_RESET;
 	qp_attr_mask = IB_QP_STATE;
 	ib_status = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
@@ -356,7 +356,7 @@ int dapl_modify_qp_state_to_rtr(struct i
 	int qp_attr_mask;
 	int ib_status;
 
-	memset(&qp_attr, 0, sizeof(qp_attr));
+	memset(&qp_attr, 0, sizeof qp_attr);
 	qp_attr.qp_state = IB_QPS_RTR;
 
 	ib_status = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask);
@@ -376,7 +376,7 @@ int dapl_modify_qp_state_to_rts(struct i
 	int qp_attr_mask;
 	int ib_status;
 
-	memset(&qp_attr, 0, sizeof(qp_attr));
+	memset(&qp_attr, 0, sizeof qp_attr);
 	qp_attr.qp_state = IB_QPS_RTS;
 
 	ib_status = ib_cm_init_qp_attr(cm_id, &qp_attr, &qp_attr_mask);
Index: linux-kernel-sizeof/dat-provider/dapl_cno_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_cno_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_cno_util.c	(working copy)
@@ -42,12 +42,12 @@ DAPL_CNO *dapl_cno_alloc(DAPL_IA *ia_ptr
 {
 	DAPL_CNO *cno_ptr;
 
-	cno_ptr = kmalloc(sizeof(*cno_ptr), GFP_ATOMIC);
+	cno_ptr = kmalloc(sizeof *cno_ptr, GFP_ATOMIC);
 	if (!cno_ptr)
 		return NULL;
 
 	/* zero the structure */
-	memset(cno_ptr, 0, sizeof(*cno_ptr));
+	memset(cno_ptr, 0, sizeof *cno_ptr);
 
 	/*
 	 * Initialize the header.
Index: linux-kernel-sizeof/dat-provider/dapl_rmr_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_rmr_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_rmr_util.c	(working copy)
@@ -33,13 +33,13 @@ DAPL_RMR *dapl_rmr_alloc(DAPL_PZ * pz)
 	DAPL_RMR *rmr;
 
 	/* Allocate LMR */
-	rmr = (DAPL_RMR *) kmalloc(sizeof(DAPL_RMR), GFP_ATOMIC);
+	rmr = (DAPL_RMR *) kmalloc(sizeof *rmr, GFP_ATOMIC);
 	if (NULL == rmr) {
 		return NULL;
 	}
 
 	/* zero the structure */
-	memset(rmr, 0, sizeof(DAPL_RMR));
+	memset(rmr, 0, sizeof *rmr);
 
 	/*
 	 * initialize the header
Index: linux-kernel-sizeof/dat-provider/dapl_ep_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_ep_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_ep_util.c	(working copy)
@@ -60,13 +60,13 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
 	DAPL_EP *ep_ptr;
 
 	/* Allocate EP */
-	ep_ptr = (DAPL_EP *) kmalloc(sizeof(DAPL_EP) + sizeof(struct sockaddr), 
+	ep_ptr = (DAPL_EP *) kmalloc(sizeof *ep_ptr + sizeof (struct sockaddr), 
 				     GFP_ATOMIC);
 	if (ep_ptr == NULL)
 		goto bail;
 
 	/* zero the structure */
-	memset(ep_ptr, 0, sizeof(DAPL_EP) + sizeof(struct sockaddr));
+	memset(ep_ptr, 0, sizeof *ep_ptr + sizeof (struct sockaddr));
 
 	/*
 	 * initialize the header
@@ -125,7 +125,7 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
 	ep_ptr->send_iov_num = ep_ptr->param.ep_attr.max_request_iov;
 
 	ep_ptr->recv_iov = kmalloc(ep_ptr->recv_iov_num * 
-				   sizeof(ib_data_segment_t), GFP_ATOMIC);
+				   sizeof *ep_ptr->recv_iov, GFP_ATOMIC);
 
 	if (NULL == ep_ptr->recv_iov) {
 		dapl_ep_dealloc(ep_ptr);
@@ -134,7 +134,7 @@ DAPL_EP *dapl_ep_alloc(DAPL_IA * ia_ptr,
 	}
 
 	ep_ptr->send_iov = kmalloc(ep_ptr->send_iov_num * 
-				   sizeof(ib_data_segment_t), GFP_ATOMIC);
+				   sizeof *ep_ptr->send_iov, GFP_ATOMIC);
 
 	if (NULL == ep_ptr->send_iov) {
 		dapl_ep_dealloc(ep_ptr);
Index: linux-kernel-sizeof/dat-provider/dapl_evd_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_evd_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_evd_util.c	(working copy)
@@ -132,13 +132,13 @@ DAPL_EVD *dapl_evd_alloc(DAPL_IA * ia_pt
 	DAPL_EVD *evd_ptr;
 
 	/* Allocate EVD */
-	evd_ptr = (DAPL_EVD *) kmalloc(sizeof(DAPL_EVD), GFP_ATOMIC);
+	evd_ptr = (DAPL_EVD *) kmalloc(sizeof *evd_ptr, GFP_ATOMIC);
 	if (!evd_ptr) {
 		goto bail;
 	}
 
 	/* zero the structure */
-	memset(evd_ptr, 0, sizeof(DAPL_EVD));
+	memset(evd_ptr, 0, sizeof *evd_ptr);
 
 	/*
 	 * initialize the header
Index: linux-kernel-sizeof/dat-provider/dapl_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_util.c	(working copy)
@@ -167,7 +167,7 @@ void dapl_dbg_log(DAPL_DBG_TYPE type, co
 
 	if (type & g_dapl_dbg_mask) {
 		va_start(args, fmt);
-                vsnprintf(buf, sizeof(buf), fmt, args);
+                vsnprintf(buf, sizeof buf, fmt, args);
                 printk(KERN_ALERT "kDAPL: %s", buf);
 		va_end(args);
 	}
Index: linux-kernel-sizeof/dat-provider/dapl_sp_util.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_sp_util.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_sp_util.c	(working copy)
@@ -64,12 +64,12 @@ DAPL_SP *dapl_sp_alloc(DAPL_IA * ia_ptr,
 	DAPL_SP *sp_ptr;
 
 	/* Allocate EP */
-	sp_ptr = (DAPL_SP *) kmalloc(sizeof(DAPL_SP), GFP_ATOMIC);
+	sp_ptr = (DAPL_SP *) kmalloc(sizeof *sp_ptr, GFP_ATOMIC);
 	if (sp_ptr == NULL) 
 		return NULL;
 
 	/* zero the structure */
-	memset(sp_ptr, 0, sizeof(DAPL_SP));
+	memset(sp_ptr, 0, sizeof *sp_ptr);
 
 	/*
 	 * initialize the header
Index: linux-kernel-sizeof/dat-provider/dapl_hash.c
===================================================================
--- linux-kernel-sizeof/dat-provider/dapl_hash.c	(revision 2423)
+++ linux-kernel-sizeof/dat-provider/dapl_hash.c	(working copy)
@@ -214,7 +214,7 @@ dapl_hash_add(DAPL_HASH_TABLEP p_table, 
 		status = TRUE;
 	} else {
 		DAPL_HASH_ELEM *newelement = (DAPL_HASH_ELEM *)
-		    kmalloc(sizeof(DAPL_HASH_ELEM), GFP_ATOMIC);
+		    kmalloc(sizeof *newelement, GFP_ATOMIC);
 		/*
 		 * Add an element to the end of the chain
 		 */
@@ -324,14 +324,14 @@ dapl_hash_delete_element(DAPL_HASH_ELEM 
 u32 dapl_hash_create(int table_size, DAPL_HASH_TABLE **pp_table)
 {
 	DAPL_HASH_TABLE *p_table;
-	int table_length = table_size * sizeof(DAPL_HASH_ELEM);
+	int table_length = table_size * sizeof (struct DAPL_HASH_ELEM);
 	u32 dat_status = DAT_SUCCESS;
 	int i;
 
 	dapl_os_assert(pp_table);
 
 	/* Allocate hash table */
-	p_table = kmalloc(sizeof(DAPL_HASH_TABLE), GFP_ATOMIC);
+	p_table = kmalloc(sizeof *p_table, GFP_ATOMIC);
 	if (NULL == p_table) {
 		dat_status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
@@ -339,7 +339,7 @@ u32 dapl_hash_create(int table_size, DAP
 	}
 
 	/* Init hash table, allocate and init and buckets */
-	memset(p_table, 0, sizeof(DAPL_HASH_TABLE));
+	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) {
Index: linux-kernel-sizeof/patches/at.c
===================================================================
--- linux-kernel-sizeof/patches/at.c	(revision 2423)
+++ linux-kernel-sizeof/patches/at.c	(working copy)
@@ -253,7 +253,7 @@ static int resolve_ip(struct ib_at_src *
 	src->dev = priv->ca;
 	src->port = priv->port;
 	src->pkey = cpu_to_be16(priv->pkey);
-	memcpy(&src->gid, ipoib_dev->dev_addr + 4, sizeof(src->gid));
+	memcpy(&src->gid, ipoib_dev->dev_addr + 4, sizeof src->gid);
 
 	if (!dgid)
 		return 0;
@@ -263,17 +263,13 @@ static int resolve_ip(struct ib_at_src *
 	 * the IB device which was found.
 	 */
 	if (rt->u.dst.neighbour->dev->flags & IFF_LOOPBACK) {
-		memcpy(dgid, ipoib_dev->dev_addr + 4,
-		       sizeof(union ib_gid));
-
+		memcpy(dgid, ipoib_dev->dev_addr + 4, sizeof *dgid);
 		return 1;
 	}
 
 	if ((NUD_CONNECTED|NUD_DELAY|NUD_PROBE) &
 	    rt->u.dst.neighbour->nud_state) {
-		memcpy(dgid, rt->u.dst.neighbour->ha + 4,
-		       sizeof(union ib_gid));
-
+		memcpy(dgid, rt->u.dst.neighbour->ha + 4, sizeof *dgid);
 		return 1;
 	}
 
@@ -300,7 +296,7 @@ static u64 alloc_req_id(void)
 static void req_init(struct async *pend, void *data, int nelem, int type,
 		     struct ib_at_completion *async_comp)
 {
-	memset(pend, 0, sizeof(*pend));
+	memset(pend, 0, sizeof *pend);
 
 	pend->id = async_comp->req_id = alloc_req_id();
 	pend->status = IB_AT_STATUS_INVALID;
@@ -454,8 +450,8 @@ static int same_path_req(struct async *a
 	struct path_req *pa = container_of(a, struct path_req, pend);
 	struct path_req *pb = container_of(b, struct path_req, pend);
 
-	return !memcmp(&pa->rt.sgid, &pb->rt.sgid, sizeof(pa->rt.sgid)) &&
-	       !memcmp(&pa->rt.dgid, &pb->rt.dgid, sizeof(pa->rt.dgid)) &&
+	return !memcmp(&pa->rt.sgid, &pb->rt.sgid, sizeof pa->rt.sgid) &&
+	       !memcmp(&pa->rt.dgid, &pb->rt.dgid, sizeof pa->rt.dgid) &&
 	       pa->rt.out_dev == pb->rt.out_dev &&
 	       pa->rt.out_port == pb->rt.out_port &&
 	       pa->rt.attr.pkey == pb->rt.attr.pkey &&
@@ -784,7 +780,7 @@ static int ib_at_arp_recv(struct sk_buff
 	 * queue IB arp packet onto work queue.
 	 */
 	DEBUG("recv IB ARP - queue work");
-	work = kmalloc(sizeof(*work), GFP_ATOMIC);
+	work = kmalloc(sizeof *work, GFP_ATOMIC);
 	if (!work)
 		goto done;
 
@@ -1000,7 +996,7 @@ static int ib_at_init(void)
 	 * Init memory pools
 	 */
 	route_req_cache = kmem_cache_create("ib_at_routes",
-					sizeof(struct route_req),
+					sizeof (struct route_req),
 					0, SLAB_HWCACHE_ALIGN,
 					NULL, NULL);
 	if (!route_req_cache) {
@@ -1010,7 +1006,7 @@ static int ib_at_init(void)
 	}
 
 	path_req_cache = kmem_cache_create("ib_at_paths",
-					sizeof(struct path_req),
+					sizeof (struct path_req),
 					0, SLAB_HWCACHE_ALIGN,
 					NULL, NULL);
 	if (!path_req_cache) {
Index: linux-kernel-sizeof/dat/dictionary.c
===================================================================
--- linux-kernel-sizeof/dat/dictionary.c	(revision 2423)
+++ linux-kernel-sizeof/dat/dictionary.c	(working copy)
@@ -96,7 +96,7 @@ u32 dat_dictionary_entry_create(struct d
 
 	BUG_ON(NULL == p_entry);
 
-	entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
+	entry = kmalloc(sizeof *entry, GFP_ATOMIC);
 	if (NULL == entry) {
 		status =
 		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
Index: linux-kernel-sizeof/dat/dr.c
===================================================================
--- linux-kernel-sizeof/dat/dr.c	(revision 2423)
+++ linux-kernel-sizeof/dat/dr.c	(working copy)
@@ -84,7 +84,7 @@ u32 dat_dr_insert(const struct dat_provi
 	unsigned long flags;
 	u32 status;
 
-	data = kmalloc(sizeof(*data), GFP_ATOMIC);
+	data = kmalloc(sizeof *data, GFP_ATOMIC);
 	if (NULL == data) {
 		status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 
 				   DAT_RESOURCE_MEMORY);
@@ -241,7 +241,7 @@ u32 dat_dr_list(int max_to_return, int *
 			goto bail;
 		}
 
-		array = kmalloc(array_size * sizeof(*array), GFP_ATOMIC);
+		array = kmalloc(array_size * sizeof *array, GFP_ATOMIC);
 		if (NULL == array) {
 			status =
 			    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
Index: linux-kernel-sizeof/dat/core.c
===================================================================
--- linux-kernel-sizeof/dat/core.c	(revision 2423)
+++ linux-kernel-sizeof/dat/core.c	(working copy)
@@ -66,7 +66,7 @@ void dat_dbg_print(DAT_DBG_TYPE type, co
 		va_list args;
 
 		va_start(args, fmt);
-		vsnprintf(buf, sizeof(buf), fmt, args);
+		vsnprintf(buf, sizeof buf, fmt, args);
 		printk(KERN_ALERT "DAT: %s", buf);
 		va_end(args);
 	}




More information about the general mailing list