Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hte: Use kasprintf() instead of fixed buffer formatting

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>

authored by

Andy Shevchenko and committed by
Dipen Patel
fc62d5e2 b7c3ca35

+4 -9
+4 -9
drivers/hte/hte.c
··· 17 17 #include <linux/debugfs.h> 18 18 #include <linux/device.h> 19 19 20 - #define HTE_TS_NAME_LEN 10 21 - 22 20 /* Global list of the HTE devices */ 23 21 static DEFINE_SPINLOCK(hte_lock); 24 22 static LIST_HEAD(hte_devices); ··· 387 389 388 390 atomic_inc(&gdev->ts_req); 389 391 390 - ei->line_name = NULL; 391 - if (!desc->attr.name) { 392 - ei->line_name = kzalloc(HTE_TS_NAME_LEN, GFP_KERNEL); 393 - if (ei->line_name) 394 - scnprintf(ei->line_name, HTE_TS_NAME_LEN, "ts_%u", 395 - desc->attr.line_id); 396 - } 392 + if (desc->attr.name) 393 + ei->line_name = NULL; 394 + else 395 + ei->line_name = kasprintf(GFP_KERNEL, "ts_%u", desc->attr.line_id); 397 396 398 397 hte_ts_dbgfs_init(desc->attr.name == NULL ? 399 398 ei->line_name : desc->attr.name, ei);