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