linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mips: math-emu: replace deprecated strcpy() in me-debugfs
@ 2025-09-02 13:23 Osama Abdelkader
  2025-09-03  1:08 ` Maciej W. Rozycki
  0 siblings, 1 reply; 2+ messages in thread
From: Osama Abdelkader @ 2025-09-02 13:23 UTC (permalink / raw)
  To: tsbogend; +Cc: linux-mips, linux-kernel, Osama Abdelkader

use strscpy() instead of deprecated strcpy().

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
v2:
change function signature to get len and the caller.
---
 arch/mips/math-emu/me-debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/mips/math-emu/me-debugfs.c b/arch/mips/math-emu/me-debugfs.c
index d5ad76b2bb67..49bf2b827ce2 100644
--- a/arch/mips/math-emu/me-debugfs.c
+++ b/arch/mips/math-emu/me-debugfs.c
@@ -37,11 +37,11 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
  * used in debugfs item names to be clearly associated to corresponding
  * MIPS FPU instructions.
  */
-static void adjust_instruction_counter_name(char *out_name, char *in_name)
+static void adjust_instruction_counter_name(char *out_name, size_t len, char *in_name)
 {
 	int i = 0;
 
-	strcpy(out_name, in_name);
+	strscpy(out_name, in_name, len);
 	while (in_name[i] != '\0') {
 		if (out_name[i] == '_')
 			out_name[i] = '.';
@@ -226,7 +226,7 @@ do {									\
 
 #define FPU_STAT_CREATE_EX(m)						\
 do {									\
-	adjust_instruction_counter_name(name, #m);			\
+	adjust_instruction_counter_name(name, sizeof(name), #m);			\
 									\
 	debugfs_create_file(name, 0444, fpuemu_debugfs_inst_dir,	\
 				(void *)FPU_EMU_STAT_OFFSET(m),		\
-- 
2.43.0


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

* Re: [PATCH v2] mips: math-emu: replace deprecated strcpy() in me-debugfs
  2025-09-02 13:23 [PATCH v2] mips: math-emu: replace deprecated strcpy() in me-debugfs Osama Abdelkader
@ 2025-09-03  1:08 ` Maciej W. Rozycki
  0 siblings, 0 replies; 2+ messages in thread
From: Maciej W. Rozycki @ 2025-09-03  1:08 UTC (permalink / raw)
  To: Osama Abdelkader; +Cc: Thomas Bogendoerfer, linux-mips, linux-kernel

On Tue, 2 Sep 2025, Osama Abdelkader wrote:

> diff --git a/arch/mips/math-emu/me-debugfs.c b/arch/mips/math-emu/me-debugfs.c
> index d5ad76b2bb67..49bf2b827ce2 100644
> --- a/arch/mips/math-emu/me-debugfs.c
> +++ b/arch/mips/math-emu/me-debugfs.c
> @@ -37,11 +37,11 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
>   * used in debugfs item names to be clearly associated to corresponding
>   * MIPS FPU instructions.
>   */
> -static void adjust_instruction_counter_name(char *out_name, char *in_name)
> +static void adjust_instruction_counter_name(char *out_name, size_t len, char *in_name)
>  {
>  	int i = 0;
>  
> -	strcpy(out_name, in_name);
> +	strscpy(out_name, in_name, len);

 It'd make sense to keep the order of the incoming parameters the same as 
the arguments here so as to avoid the need for register shuffling.

  Maciej

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

end of thread, other threads:[~2025-09-03  1:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-02 13:23 [PATCH v2] mips: math-emu: replace deprecated strcpy() in me-debugfs Osama Abdelkader
2025-09-03  1:08 ` Maciej W. Rozycki

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).