]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hte: Use kasprintf() instead of fixed buffer formatting
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 10 Oct 2023 14:11:23 +0000 (17:11 +0300)
committerDipen Patel <dipenp@nvidia.com>
Fri, 27 Oct 2023 21:09:22 +0000 (14:09 -0700)
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>
Reviewed-by: Dipen Patel <dipenp@nvidia.com>
Signed-off-by: Dipen Patel <dipenp@nvidia.com>
drivers/hte/hte.c

index 1fd8d2d4528bcc2f40231d739bc6e4849a67475d..23a6eeb8c506c29d74bc720f35b3eb273a3f6c26 100644 (file)
@@ -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);