[dm-devel] [PATCH V2 5/5] multipathd: remove useless memset after MALLOC in alloc_waiteri func

Martin Wilck mwilck at suse.com
Fri Aug 21 11:18:50 UTC 2020


On Fri, 2020-08-21 at 19:01 +0800, Zhiqiang Liu wrote:
> MALLOC(x) maps to calloc(1, x), which already init var to zero.
> In alloc_waiter func, the superfluous memset(wp) call is useless,
> and it should be removed.
> 
> V1->V2:
> - remove useless memset call after MALLOC (as suggested by Martin)

Reading this, I realize that we don't need alloc_waiter() at all.
Anyway:

Reviewed-by: Martin Wilck <mwilck at suse.com>

> Signed-off-by: Zhiqiang Liu <liuzhiqiang26 at huawei.com>
> Signed-off-by: lixiaokeng <lixiaokeng at huawei.com>
> ---
>  multipathd/waiter.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/multipathd/waiter.c b/multipathd/waiter.c
> index e6457663..da4017b9 100644
> --- a/multipathd/waiter.c
> +++ b/multipathd/waiter.c
> @@ -29,13 +29,7 @@ struct mutex_lock waiter_lock = { .mutex =
> PTHREAD_MUTEX_INITIALIZER };
> 
>  static struct event_thread *alloc_waiter (void)
>  {
> -
> -	struct event_thread *wp;
> -
> -	wp = (struct event_thread *)MALLOC(sizeof(struct
> event_thread));
> -	memset(wp, 0, sizeof(struct event_thread));
> -
> -	return wp;
> +	return (struct event_thread *)MALLOC(sizeof(struct
> event_thread));
>  }
> 
>  static void free_waiter (void *data)





More information about the dm-devel mailing list