From 435eb142bbd7c90299ffce2d389395927b1f7692 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Sat, 14 Feb 2015 09:59:10 -0500 Subject: [PATCH] examples: remove unneeded casts *alloc() routines return void * and therefore cast is not needed. Signed-off-by: Stephen Hemminger Reviewed-by: Bruce Richardson [Thomas: reverse num and size parameters in vhost calloc] --- examples/kni/main.c | 4 ++-- examples/l3fwd-acl/main.c | 4 ++-- examples/vhost/main.c | 7 ++++--- examples/vhost_xen/vhost_monitor.c | 2 +- examples/vhost_xen/xenstore_parse.c | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/kni/main.c b/examples/kni/main.c index 45b96bcdc3..2bff1e1379 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -462,8 +462,8 @@ parse_config(const char *arg) goto fail; } kni_port_params_array[port_id] = - (struct kni_port_params*)rte_zmalloc("KNI_port_params", - sizeof(struct kni_port_params), RTE_CACHE_LINE_SIZE); + rte_zmalloc("KNI_port_params", + sizeof(struct kni_port_params), RTE_CACHE_LINE_SIZE); kni_port_params_array[port_id]->port_id = port_id; kni_port_params_array[port_id]->lcore_rx = (uint8_t)int_fld[i++]; diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c index e851768f18..9d84b2091f 100644 --- a/examples/l3fwd-acl/main.c +++ b/examples/l3fwd-acl/main.c @@ -1044,13 +1044,13 @@ add_rules(const char *rule_path, fseek(fh, 0, SEEK_SET); - acl_rules = (uint8_t *)calloc(acl_num, rule_size); + acl_rules = calloc(acl_num, rule_size); if (NULL == acl_rules) rte_exit(EXIT_FAILURE, "%s: failed to malloc memory\n", __func__); - route_rules = (uint8_t *)calloc(route_num, rule_size); + route_rules = calloc(route_num, rule_size); if (NULL == route_rules) rte_exit(EXIT_FAILURE, "%s: failed to malloc memory\n", diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 334e2fec7c..9219a24660 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -2615,9 +2615,10 @@ new_device (struct virtio_net *dev) } - vdev->regions_hpa = (struct virtio_memory_regions_hpa *) rte_zmalloc("vhost hpa region", - sizeof(struct virtio_memory_regions_hpa) * vdev->nregions_hpa, - RTE_CACHE_LINE_SIZE); + vdev->regions_hpa = rte_calloc("vhost hpa region", + vdev->nregions_hpa, + sizeof(struct virtio_memory_regions_hpa), + RTE_CACHE_LINE_SIZE); if (vdev->regions_hpa == NULL) { RTE_LOG(ERR, VHOST_CONFIG, "Cannot allocate memory for hpa region\n"); rte_free(vdev); diff --git a/examples/vhost_xen/vhost_monitor.c b/examples/vhost_xen/vhost_monitor.c index f683989183..9d99962ce1 100644 --- a/examples/vhost_xen/vhost_monitor.c +++ b/examples/vhost_xen/vhost_monitor.c @@ -138,7 +138,7 @@ add_xen_guest(int32_t dom_id) if ((guest = get_xen_guest(dom_id)) != NULL) return guest; - guest = (struct xen_guest * )calloc(1, sizeof(struct xen_guest)); + guest = calloc(1, sizeof(struct xen_guest)); if (guest) { RTE_LOG(ERR, XENHOST, " %s: return newly created guest with %d rings\n", __func__, guest->vring_num); TAILQ_INSERT_TAIL(&guest_root, guest, next); diff --git a/examples/vhost_xen/xenstore_parse.c b/examples/vhost_xen/xenstore_parse.c index 9441639a32..df191acda2 100644 --- a/examples/vhost_xen/xenstore_parse.c +++ b/examples/vhost_xen/xenstore_parse.c @@ -248,8 +248,8 @@ parse_gntnode(int dom_id, char *path) goto err; } - gntnode = (struct xen_gntnode *)calloc(1, sizeof(struct xen_gntnode)); - gnt = (struct xen_gnt *)calloc(gref_num, sizeof(struct xen_gnt)); + gntnode = calloc(1, sizeof(struct xen_gntnode)); + gnt = calloc(gref_num, sizeof(struct xen_gnt)); if (gnt == NULL || gntnode == NULL) goto err; -- 2.20.1