[dpdk-dev,6/6] examples: remove unneeded casts
Commit Message
*alloc() routines return void * and therefore cast is not needed.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/kni/main.c | 4 ++--
examples/l3fwd-acl/main.c | 4 ++--
examples/vhost/main.c | 7 ++++---
3 files changed, 8 insertions(+), 7 deletions(-)
Comments
On Sat, Feb 14, 2015 at 09:59:10AM -0500, Stephen Hemminger wrote:
> *alloc() routines return void * and therefore cast is not needed.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> examples/kni/main.c | 4 ++--
> examples/l3fwd-acl/main.c | 4 ++--
> examples/vhost/main.c | 7 ++++---
> 3 files changed, 8 insertions(+), 7 deletions(-)
>
... <snip> ...
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index 3a35359..a96b19f 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -2592,9 +2592,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",
> + sizeof(struct virtio_memory_regions_hpa),
> + vdev->nregions_hpa,
> + RTE_CACHE_LINE_SIZE);
I know functionally it probably doesn't make a difference, but I think your
"num" and "size" parameters are reversed here.
/Bruce
@@ -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++];
@@ -1047,13 +1047,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",
@@ -2592,9 +2592,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",
+ sizeof(struct virtio_memory_regions_hpa),
+ vdev->nregions_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);