Message ID | 20231010141123.3909596-1-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp231424vqb; Tue, 10 Oct 2023 07:12:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvbh7biTDIHGyADbmgb/d4WTavmxy2jhtIMYObAPUP/9XYhnBIIQehaUcBWjg4SvXQsHuF X-Received: by 2002:a17:902:d702:b0:1c5:f4c7:b4e4 with SMTP id w2-20020a170902d70200b001c5f4c7b4e4mr14862264ply.39.1696947141927; Tue, 10 Oct 2023 07:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696947141; cv=none; d=google.com; s=arc-20160816; b=Nk91+yDaOximjNPRwObQT2AW4GWo651GT2uz91f/sO4/bk7Mgx+aZu//hxJhhrkgDa a0ar/jKNhbwDKlXA1g+PpjsSYsjBWmiq49yBFdS09+Bvud9KUsxgdLnJj9Puc1RJfTRL mi0BNbUg6hTPVhckd+TXogT0jaxx8jhwsh7d64l8y4yr+Cbm94WF68GwCN5gL24Qz5nM KEnhD4VSPZ5rQUDnPLTU0/P5OANgZVkcE5kOA849ukpf+uc+EIqkjJTH4QkLAWG9nwq2 R92/VaBjkP0aHyPWGHvDnNTtCmPOtV2JUT3YF0IEaA31ol1k+VhHpFB3KW2h2p19bNlm igiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AJdk+y8NXF+RoH9Ae4ORRCDGI6GEwlgz+hw2CvaEpW0=; fh=ZJ836GL6jorYb+SbCfBeO8zhoMwg3TfE6doBJV4m2wI=; b=LYnCMnp40TMuTdAQqxEQMVizY38tma62LwAjLx0+pHfNHsS0Z9Ug8yoZjQfjjEt7rs HBp/hNJPebNWfliI3F7ncGZBB07ph4FGlYknvOQxMb2UDq8U7I85dF219RWmk6LFFgIN ZyhJNuZkfQt2O8GCGIOF9Invi/XzsvWfBbHVW95PR1Xbjys9ILg6uQ3hGrughlVbXfMS CKQ5Vdj2YInFqBeZ+3/ix6uDemFx8L+rnon9xrzxpNdz/8D9VQqc+OhAaYZ79BReMjRW ZFJLO62Ran24JfqJOMeFd6yGLI1sJUQmCc8Pr8Umo1ejgNBGQ7QaE9RK9oFdTnBLrJ8i MOyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E1zVf4tq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ik6-20020a170902ab0600b001c74ae78c7bsi509664plb.377.2023.10.10.07.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E1zVf4tq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 68FAA80D7059; Tue, 10 Oct 2023 07:12:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232455AbjJJOLv (ORCPT <rfc822;rua109.linux@gmail.com> + 20 others); Tue, 10 Oct 2023 10:11:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbjJJOLu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 10 Oct 2023 10:11:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4579FA7 for <linux-kernel@vger.kernel.org>; Tue, 10 Oct 2023 07:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696947106; x=1728483106; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2VBQXVArfIBgHPpUcs1zlQhsNpmKngH8nu0wk1tf7IE=; b=E1zVf4tqyawx63DGJ/6zR3z2nyHb8/WtxjTki3wB7IFd1UIvyzLu625H bB2+Zz5/a3BtBht2QfTsVSX74/v4BPxrnNH86enU7tfy9b1SF9E41m/3Y ciiU/RxIqbPLZwhkx7HKuhVFsp5sbEZG5Le5O75wMZyb1EzTBftkAedCS q4boTpv5nhH21GQnwCjLTf9WV/H8maMnFzg3vl2YuCxu5ENuTsxfPTacg 9tpyYZRa3ToqshT2T+B6FGjUhJUJopiaD/KlIWNin5oCbCcNPIfdbGmlf GaQnO0W7h50JI4KDjIFzqX3wzfIiDo4fDJxoElS2lTssod0umu2IutJJa Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="387241769" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="387241769" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 07:11:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="1084802382" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="1084802382" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 10 Oct 2023 07:11:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 49F5B35A; Tue, 10 Oct 2023 17:11:25 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Dipen Patel <dipenp@nvidia.com>, timestamp@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 1/1] hte: Use kasprintf() instead of fixed buffer formatting Date: Tue, 10 Oct 2023 17:11:23 +0300 Message-Id: <20231010141123.3909596-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:12:07 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779378046515187881 X-GMAIL-MSGID: 1779378046515187881 |
Series |
[v1,1/1] hte: Use kasprintf() instead of fixed buffer formatting
|
|
Commit Message
Andy Shevchenko
Oct. 10, 2023, 2:11 p.m. UTC
Improve readability and maintainability by replacing a hardcoded string
allocation and formatting by the use of the kasprintf() helper.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hte/hte.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
Comments
On 10/10/23 7:11 AM, Andy Shevchenko wrote: > Improve readability and maintainability by replacing a hardcoded string > allocation and formatting by the use of the kasprintf() helper. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/hte/hte.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/drivers/hte/hte.c b/drivers/hte/hte.c > index 1fd8d2d4528b..23a6eeb8c506 100644 > --- a/drivers/hte/hte.c > +++ b/drivers/hte/hte.c > @@ -17,8 +17,6 @@ > #include <linux/debugfs.h> > #include <linux/device.h> > > -#define HTE_TS_NAME_LEN 10 > - > /* Global list of the HTE devices */ > static DEFINE_SPINLOCK(hte_lock); > static LIST_HEAD(hte_devices); > @@ -389,13 +387,10 @@ static int __hte_req_ts(struct hte_ts_desc *desc, hte_ts_cb_t cb, > > atomic_inc(&gdev->ts_req); > > - ei->line_name = NULL; > - if (!desc->attr.name) { > - ei->line_name = kzalloc(HTE_TS_NAME_LEN, GFP_KERNEL); > - if (ei->line_name) > - scnprintf(ei->line_name, HTE_TS_NAME_LEN, "ts_%u", > - desc->attr.line_id); > - } > + if (desc->attr.name) > + ei->line_name = NULL; > + else > + ei->line_name = kasprintf(GFP_KERNEL, "ts_%u", desc->attr.line_id); > > hte_ts_dbgfs_init(desc->attr.name == NULL ? > ei->line_name : desc->attr.name, ei); Reviewed-by: Dipen Patel <dipenp@nvidia.com>
On Tue, Oct 10, 2023 at 09:12:09AM -0700, Dipen Patel wrote: > On 10/10/23 7:11 AM, Andy Shevchenko wrote: > > Improve readability and maintainability by replacing a hardcoded string > > allocation and formatting by the use of the kasprintf() helper. ... > > hte_ts_dbgfs_init(desc->attr.name == NULL ? > > ei->line_name : desc->attr.name, ei); > Reviewed-by: Dipen Patel <dipenp@nvidia.com> Thanks! Who is the maintainer of this code? If not you, shouldn't MAINTAINERS to be updated to reflect that?
On 10/27/23 5:39 AM, Andy Shevchenko wrote: > On Tue, Oct 10, 2023 at 09:12:09AM -0700, Dipen Patel wrote: >> On 10/10/23 7:11 AM, Andy Shevchenko wrote: >>> Improve readability and maintainability by replacing a hardcoded string >>> allocation and formatting by the use of the kasprintf() helper. > > ... > >>> hte_ts_dbgfs_init(desc->attr.name == NULL ? >>> ei->line_name : desc->attr.name, ei); >> Reviewed-by: Dipen Patel <dipenp@nvidia.com> > > Thanks! > > Who is the maintainer of this code? > If not you, shouldn't MAINTAINERS to be updated to reflect that? > I am the maintainer, I am not sure how did I miss this patch for my for-next. Let me push this right away.
diff --git a/drivers/hte/hte.c b/drivers/hte/hte.c index 1fd8d2d4528b..23a6eeb8c506 100644 --- a/drivers/hte/hte.c +++ b/drivers/hte/hte.c @@ -17,8 +17,6 @@ #include <linux/debugfs.h> #include <linux/device.h> -#define HTE_TS_NAME_LEN 10 - /* Global list of the HTE devices */ static DEFINE_SPINLOCK(hte_lock); static LIST_HEAD(hte_devices); @@ -389,13 +387,10 @@ static int __hte_req_ts(struct hte_ts_desc *desc, hte_ts_cb_t cb, atomic_inc(&gdev->ts_req); - ei->line_name = NULL; - if (!desc->attr.name) { - ei->line_name = kzalloc(HTE_TS_NAME_LEN, GFP_KERNEL); - if (ei->line_name) - scnprintf(ei->line_name, HTE_TS_NAME_LEN, "ts_%u", - desc->attr.line_id); - } + if (desc->attr.name) + ei->line_name = NULL; + else + ei->line_name = kasprintf(GFP_KERNEL, "ts_%u", desc->attr.line_id); hte_ts_dbgfs_init(desc->attr.name == NULL ? ei->line_name : desc->attr.name, ei);