Re: [PATCH rdma-core] treewide: Don't cast malloc() output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28-Feb-19 15:30, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> malloc() returns void* output which doesn't need to be casted.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> ---
> PR: https://github.com/linux-rdma/rdma-core/pull/481
> ---
>  ibacm/src/libacm.c               | 4 ++--
>  iwpmd/iwarp_pm_helper.c          | 2 +-
>  iwpmd/iwarp_pm_server.c          | 8 ++++----
>  providers/hns/hns_roce_u_verbs.c | 2 +-
>  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c
> index da9a053b..ec4e8531 100644
> --- a/ibacm/src/libacm.c
> +++ b/ibacm/src/libacm.c
> @@ -416,8 +416,8 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data, uint8_t port)
>  	}
> 
>  	len = be16toh(hdr.length) - sizeof(hdr);
> -	netw_edata = (struct acm_ep_config_data *)malloc(len);
> -	host_edata = (struct acm_ep_config_data *)malloc(len);
> +	netw_edata = malloc(len);
> +	host_edata = malloc(len);
>  	if (!netw_edata || !host_edata) {
>  		ret = ACM_STATUS_ENOMEM;
>  		goto out;
> diff --git a/iwpmd/iwarp_pm_helper.c b/iwpmd/iwarp_pm_helper.c
> index 16311a9c..abab6162 100644
> --- a/iwpmd/iwarp_pm_helper.c
> +++ b/iwpmd/iwarp_pm_helper.c
> @@ -579,7 +579,7 @@ void form_iwpm_send_msg(int pm_sock, struct sockaddr_storage *dest,
>   */
>  int add_iwpm_pending_msg(iwpm_send_msg *send_msg)
>  {
> -	iwpm_pending_msg *pending_msg = (iwpm_pending_msg *)malloc(sizeof(iwpm_pending_msg));
> +	iwpm_pending_msg *pending_msg = malloc(sizeof(iwpm_pending_msg));
>  	if (!pending_msg) {
>  		syslog(LOG_WARNING, "add_iwpm_pending_msg: Unable to allocate message.\n");
>  		return -ENOMEM;
> diff --git a/iwpmd/iwarp_pm_server.c b/iwpmd/iwarp_pm_server.c
> index aacadc2b..605e5ea7 100644
> --- a/iwpmd/iwarp_pm_server.c
> +++ b/iwpmd/iwarp_pm_server.c
> @@ -51,7 +51,7 @@ static int mapinfo_num_list[IWARP_PM_MAX_CLIENTS];   /* list of iwarp port mappe
>  static int pmv4_sock, pmv6_sock, netlink_sock, pmv4_client_sock, pmv6_client_sock;
> 
>  static pthread_t map_req_thread; /* handling mapping requests timeout */
> -pthread_cond_t cond_req_complete;
> +pthread_cond_t cond_req_complete;

What is changed here?

>  pthread_mutex_t map_req_mutex = PTHREAD_MUTEX_INITIALIZER;
>  int wake = 0; /* set if map_req_thread is wake */
> 
> @@ -493,7 +493,7 @@ static int process_iwpm_query_mapping(struct nlmsghdr *req_nlh, int client_idx,
>  			"remote port = 0x%04X\n",
>  			be16toh(msg_parms.cpport), be16toh(msg_parms.apport));
>  	ret = -ENOMEM;
> -        send_msg = (iwpm_send_msg *)malloc(sizeof(iwpm_send_msg));
> +	send_msg = malloc(sizeof(iwpm_send_msg));
>  	if (!send_msg) {
>  		str_err = "Unable to allocate send msg buffer";
>  		goto query_mapping_free_error;
> @@ -683,7 +683,7 @@ static int process_iwpm_wire_request(iwpm_msg_parms *msg_parms, int nl_sock,
>  		return 0;
>  	}
>  	/* allocate response message */
> -        send_msg = (iwpm_send_msg *)malloc(sizeof(iwpm_send_msg));
> +	send_msg = malloc(sizeof(iwpm_send_msg));
>  	if (!send_msg) {
>  		syslog(LOG_WARNING, "process_wire_request: Unable to allocate send msg.\n");
>  		return -ENOMEM;
> @@ -1138,7 +1138,7 @@ static int process_iwpm_netlink_msg(int nl_sock)
>  	const char *str_err = "";
>  	int ret = 0;
> 
> -	recv_buffer = (char *)malloc(NLMSG_SPACE(IWARP_PM_RECV_PAYLOAD));
> +	recv_buffer = malloc(NLMSG_SPACE(IWARP_PM_RECV_PAYLOAD));
>  	if (!recv_buffer) {
>  		ret = -ENOMEM;
>  		str_err = "Unable to allocate receive socket buffer";
> diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
> index 3bc63ac2..8ae600aa 100644
> --- a/providers/hns/hns_roce_u_verbs.c
> +++ b/providers/hns/hns_roce_u_verbs.c
> @@ -91,7 +91,7 @@ struct ibv_pd *hns_roce_u_alloc_pd(struct ibv_context *context)
>  	struct hns_roce_pd *pd;
>  	struct hns_roce_alloc_pd_resp resp = {};
> 
> -	pd = (struct hns_roce_pd *)malloc(sizeof(*pd));
> +	pd = malloc(sizeof(*pd));
>  	if (!pd)
>  		return NULL;
> 
> --
> 2.19.1
> 




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux