timestamp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] hte: Use kasprintf() instead of fixed buffer formatting
@ 2023-10-10 14:11 Andy Shevchenko
  2023-10-10 16:12 ` Dipen Patel
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2023-10-10 14:11 UTC (permalink / raw)
  To: Dipen Patel, timestamp, linux-kernel; +Cc: Andy Shevchenko

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);
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] hte: Use kasprintf() instead of fixed buffer formatting
  2023-10-10 14:11 [PATCH v1 1/1] hte: Use kasprintf() instead of fixed buffer formatting Andy Shevchenko
@ 2023-10-10 16:12 ` Dipen Patel
  2023-10-27 12:39   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Dipen Patel @ 2023-10-10 16:12 UTC (permalink / raw)
  To: Andy Shevchenko, timestamp, linux-kernel

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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] hte: Use kasprintf() instead of fixed buffer formatting
  2023-10-10 16:12 ` Dipen Patel
@ 2023-10-27 12:39   ` Andy Shevchenko
  2023-10-27 21:03     ` Dipen Patel
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2023-10-27 12:39 UTC (permalink / raw)
  To: Dipen Patel; +Cc: timestamp, linux-kernel

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?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] hte: Use kasprintf() instead of fixed buffer formatting
  2023-10-27 12:39   ` Andy Shevchenko
@ 2023-10-27 21:03     ` Dipen Patel
  0 siblings, 0 replies; 4+ messages in thread
From: Dipen Patel @ 2023-10-27 21:03 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: timestamp, linux-kernel

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-27 21:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-10 14:11 [PATCH v1 1/1] hte: Use kasprintf() instead of fixed buffer formatting Andy Shevchenko
2023-10-10 16:12 ` Dipen Patel
2023-10-27 12:39   ` Andy Shevchenko
2023-10-27 21:03     ` Dipen Patel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).