From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1529FC43460 for ; Sun, 18 Apr 2021 21:28:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD39B610C8 for ; Sun, 18 Apr 2021 21:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbhDRV2r (ORCPT ); Sun, 18 Apr 2021 17:28:47 -0400 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:55548 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbhDRV2q (ORCPT ); Sun, 18 Apr 2021 17:28:46 -0400 Received: from [192.168.1.18] ([86.243.172.93]) by mwinf5d25 with ME id uMUG2400321Fzsu03MUGK5; Sun, 18 Apr 2021 23:28:16 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 18 Apr 2021 23:28:16 +0200 X-ME-IP: 86.243.172.93 Subject: Re: [PATCH] net/mlx5: Use kasprintf instead of hand-writing it To: Bart Van Assche , saeedm@nvidia.com, leon@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <46235ec010551d2788483ce636686a61345e40ba.1618643703.git.christophe.jaillet@wanadoo.fr> <131988e1-2327-99f8-95e1-778d653c36ec@acm.org> From: Christophe JAILLET Message-ID: <8513235a-eed2-7007-a873-6464df8cb3c9@wanadoo.fr> Date: Sun, 18 Apr 2021 23:28:16 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <131988e1-2327-99f8-95e1-778d653c36ec@acm.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Le 18/04/2021 à 22:03, Bart Van Assche a écrit : > On 4/17/21 12:16 AM, Christophe JAILLET wrote: >> 'kasprintf()' can replace a kmalloc/strcpy/strcat sequence. >> It is less verbose and avoid the use of a magic number (64). >> >> Anyway, the underlying 'alloc_workqueue()' would only keep the 24 first >> chars (i.e. sizeof(struct workqueue_struct->name) = WQ_NAME_LEN). >> >> Signed-off-by: Christophe JAILLET >> --- >> drivers/net/ethernet/mellanox/mlx5/core/health.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c >> index 9ff163c5bcde..a5383e701b4b 100644 >> --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c >> +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c >> @@ -802,12 +802,10 @@ int mlx5_health_init(struct mlx5_core_dev *dev) >> mlx5_fw_reporters_create(dev); >> >> health = &dev->priv.health; >> - name = kmalloc(64, GFP_KERNEL); >> + name = kasprintf(GFP_KERNEL, "mlx5_health%s", dev_name(dev->device)); >> if (!name) >> goto out_err; >> >> - strcpy(name, "mlx5_health"); >> - strcat(name, dev_name(dev->device)); >> health->wq = create_singlethread_workqueue(name); >> kfree(name); >> if (!health->wq) > > Instead of modifying the mlx5 driver, please change the definition of > the create_singlethread_workqueue() such that it accept a format > specifier and a variable number of arguments. > Agreed. I've sent another patch serie which is more elegant. Thanks for the feedback. CJ > Thanks, > > Bart. > > >