public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] bus: rifsc: Replace snprintf("%s") with strscpy
@ 2026-02-23 21:12 Thorsten Blum
  2026-02-24  9:06 ` Gatien CHEVALLIER
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-02-23 21:12 UTC (permalink / raw)
  To: Gatien Chevallier, Maxime Coquelin, Alexandre Torgue
  Cc: Thorsten Blum, linux-stm32, linux-arm-kernel, linux-kernel

Replace snprintf("%s", ...) with the faster and more direct strscpy().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/bus/stm32_rifsc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/stm32_rifsc.c b/drivers/bus/stm32_rifsc.c
index debeaf8ea1bd..ba65ad21434b 100644
--- a/drivers/bus/stm32_rifsc.c
+++ b/drivers/bus/stm32_rifsc.c
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/string.h>
 #include <linux/types.h>
 
 #include "stm32_firewall.h"
@@ -450,7 +451,7 @@ static void stm32_rifsc_fill_rimu_dbg_entry(struct rifsc_dbg_private *rifsc,
 	const struct stm32_rifsc_resources_names *dbg_names = rifsc->res_names;
 	u32 rimc_attr = readl_relaxed(rifsc->mmio + RIFSC_RIMC_ATTR0 + 0x4 * i);
 
-	snprintf(dbg_entry->m_name, sizeof(dbg_entry->m_name), "%s", dbg_names->initiator_names[i]);
+	strscpy(dbg_entry->m_name, dbg_names->initiator_names[i]);
 	dbg_entry->m_cid = FIELD_GET(RIFSC_RIMC_MCID_MASK, rimc_attr);
 	dbg_entry->cidsel = rimc_attr & RIFSC_RIMC_CIDSEL;
 	dbg_entry->m_sec = rimc_attr & RIFSC_RIMC_MSEC;
@@ -469,8 +470,7 @@ static void stm32_rifsc_fill_dev_dbg_entry(struct rifsc_dbg_private *rifsc,
 	sec_cfgr = readl_relaxed(rifsc->mmio + RIFSC_RISC_SECCFGR0 + 0x4 * reg_id);
 	priv_cfgr = readl_relaxed(rifsc->mmio + RIFSC_RISC_PRIVCFGR0 + 0x4 * reg_id);
 
-	snprintf(dbg_entry->dev_name, sizeof(dbg_entry->dev_name), "%s",
-		 dbg_names->device_names[i]);
+	strscpy(dbg_entry->dev_name, dbg_names->device_names[i]);
 	dbg_entry->dev_id = i;
 	dbg_entry->dev_cid_filt_en = cid_cfgr & CIDCFGR_CFEN;
 	dbg_entry->dev_sem_en = cid_cfgr & CIDCFGR_SEMEN;
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4



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

* Re: [PATCH] bus: rifsc: Replace snprintf("%s") with strscpy
  2026-02-23 21:12 [PATCH] bus: rifsc: Replace snprintf("%s") with strscpy Thorsten Blum
@ 2026-02-24  9:06 ` Gatien CHEVALLIER
  0 siblings, 0 replies; 2+ messages in thread
From: Gatien CHEVALLIER @ 2026-02-24  9:06 UTC (permalink / raw)
  To: Thorsten Blum, Maxime Coquelin, Alexandre Torgue
  Cc: linux-stm32, linux-arm-kernel, linux-kernel



On 2/23/26 22:12, Thorsten Blum wrote:
> Replace snprintf("%s", ...) with the faster and more direct strscpy().
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>   drivers/bus/stm32_rifsc.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/bus/stm32_rifsc.c b/drivers/bus/stm32_rifsc.c
> index debeaf8ea1bd..ba65ad21434b 100644
> --- a/drivers/bus/stm32_rifsc.c
> +++ b/drivers/bus/stm32_rifsc.c
> @@ -15,6 +15,7 @@
>   #include <linux/of.h>
>   #include <linux/of_platform.h>
>   #include <linux/platform_device.h>
> +#include <linux/string.h>
>   #include <linux/types.h>
>   
>   #include "stm32_firewall.h"
> @@ -450,7 +451,7 @@ static void stm32_rifsc_fill_rimu_dbg_entry(struct rifsc_dbg_private *rifsc,
>   	const struct stm32_rifsc_resources_names *dbg_names = rifsc->res_names;
>   	u32 rimc_attr = readl_relaxed(rifsc->mmio + RIFSC_RIMC_ATTR0 + 0x4 * i);
>   
> -	snprintf(dbg_entry->m_name, sizeof(dbg_entry->m_name), "%s", dbg_names->initiator_names[i]);
> +	strscpy(dbg_entry->m_name, dbg_names->initiator_names[i]);

Hello,

I was expecting a third argument but looking at string.h I
now see it's optional if dst is an array. So:

Acked-by: Gatien Chevallier <gatien.chevallier@foss.st.com>

Thanks,
Gatien

>   	dbg_entry->m_cid = FIELD_GET(RIFSC_RIMC_MCID_MASK, rimc_attr);
>   	dbg_entry->cidsel = rimc_attr & RIFSC_RIMC_CIDSEL;
>   	dbg_entry->m_sec = rimc_attr & RIFSC_RIMC_MSEC;
> @@ -469,8 +470,7 @@ static void stm32_rifsc_fill_dev_dbg_entry(struct rifsc_dbg_private *rifsc,
>   	sec_cfgr = readl_relaxed(rifsc->mmio + RIFSC_RISC_SECCFGR0 + 0x4 * reg_id);
>   	priv_cfgr = readl_relaxed(rifsc->mmio + RIFSC_RISC_PRIVCFGR0 + 0x4 * reg_id);
>   
> -	snprintf(dbg_entry->dev_name, sizeof(dbg_entry->dev_name), "%s",
> -		 dbg_names->device_names[i]);
> +	strscpy(dbg_entry->dev_name, dbg_names->device_names[i]);
>   	dbg_entry->dev_id = i;
>   	dbg_entry->dev_cid_filt_en = cid_cfgr & CIDCFGR_CFEN;
>   	dbg_entry->dev_sem_en = cid_cfgr & CIDCFGR_SEMEN;



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

end of thread, other threads:[~2026-02-24  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 21:12 [PATCH] bus: rifsc: Replace snprintf("%s") with strscpy Thorsten Blum
2026-02-24  9:06 ` Gatien CHEVALLIER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox