[PATCH 07/28] scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init()

From: Bill Wendling

Date: Tue Sep 15 2026 - 04:32:33 EST


Similar to bfa_fcs_fabric_nsymb_init(), bfa_fcs_fabric_psymb_init()
builds the port symbolic name using strscpy() and a chain of seven or
eight strlcat() calls.

In preparation for removing the deprecated strlcat() API[1], replace the
chained strscpy() and strlcat() calls with a single snprintf() call.

Link: https://github.com/KSPP/linux/issues/370 [1]
Cc: codemender-patching+linux@xxxxxxxxxx
Assisted-by: Gemini-3.5-Pro:20241215 [editor_update_file, make_kernel_build_single_file]
Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx>
---
Cc: Russell King <linux@xxxxxxxxxxxxxxx>
Cc: Huacai Chen <chenhuacai@xxxxxxxxxx>
Cc: WANG Xuerui <kernel@xxxxxxxxxx>
Cc: Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>
Cc: "James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>
Cc: Helge Deller <deller@xxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: x86@xxxxxxxxxx
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Tony Luck <tony.luck@xxxxxxxxx>
Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
Cc: Maxime Ripard <mripard@xxxxxxxxxx>
Cc: Thomas Zimmermann <tzimmermann@xxxxxxx>
Cc: David Airlie <airlied@xxxxxxxxx>
Cc: Simona Vetter <simona@xxxxxxxx>
Cc: Matthew Brost <matthew.brost@xxxxxxxxx>
Cc: "Thomas Hellström" <thomas.hellstrom@xxxxxxxxxxxxxxx>
Cc: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>
Cc: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
Cc: Matthias Schwarzott <zzam@xxxxxxxxxx>
Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
Cc: Tony Nguyen <anthony.l.nguyen@xxxxxxxxx>
Cc: Przemek Kitszel <przemyslaw.kitszel@xxxxxxxxx>
Cc: Andrew Lunn <andrew+netdev@xxxxxxx>
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
Cc: Arend van Spriel <arend.vanspriel@xxxxxxxxxxxx>
Cc: Rob Herring <robh@xxxxxxxxxx>
Cc: Saravana Kannan <saravanak@xxxxxxxxxx>
Cc: Krzysztof Kozlowski <krzk@xxxxxxxxxx>
Cc: Sylwester Nawrocki <s.nawrocki@xxxxxxxxxxx>
Cc: Peter Griffin <peter.griffin@xxxxxxxxxx>
Cc: Alim Akhtar <alim.akhtar@xxxxxxxxxxx>
Cc: Linus Walleij <linusw@xxxxxxxxxx>
Cc: Anil Gurumurthy <anil.gurumurthy@xxxxxxxxxx>
Cc: Sudarsana Kalluru <sudarsana.kalluru@xxxxxxxxxx>
Cc: "Martin K. Petersen" <mkp@xxxxxxxxxx>
Cc: Trond Myklebust <trondmy@xxxxxxxxxx>
Cc: Anna Schumaker <anna@xxxxxxxxxx>
Cc: Mike Marshall <hubcap@xxxxxxxxxxxx>
Cc: Martin Brandenburg <martin@xxxxxxxxxxxx>
Cc: Kees Cook <kees@xxxxxxxxxx>
Cc: Jiri Pirko <jiri@xxxxxxxxxxx>
Cc: Simon Horman <horms@xxxxxxxxxx>
Cc: Chuck Lever <cel@xxxxxxxxxx>
Cc: Jeff Layton <jlayton@xxxxxxxxxx>
Cc: NeilBrown <neil@xxxxxxxxxx>
Cc: Olga Kornievskaia <okorniev@xxxxxxxxxx>
Cc: Dai Ngo <Dai.Ngo@xxxxxxxxxx>
Cc: Tom Talpey <tom@xxxxxxxxxx>
Cc: Jaroslav Kysela <perex@xxxxxxxx>
Cc: Takashi Iwai <tiwai@xxxxxxxx>
Cc: Bill Wendling <morbo@xxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx>
Cc: Kanglong Wang <wangkanglong@xxxxxxxxxxx>
Cc: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
Cc: Qiang Ma <maqianga@xxxxxxxxxxxxx>
Cc: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Cc: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
Cc: Ard Biesheuvel <ardb@xxxxxxxxxx>
Cc: Breno Leitao <leitao@xxxxxxxxxx>
Cc: Thorsten Blum <blum@xxxxxxxxxx>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@xxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Lyude Paul <lyude@xxxxxxxxxx>
Cc: Ashutosh Desai <ashutoshdesai993@xxxxxxxxx>
Cc: Imre Deak <imre.deak@xxxxxxxxx>
Cc: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxxxxxxxx>
Cc: Johan Hovold <johan@xxxxxxxxxx>
Cc: Johannes Berg <johannes.berg@xxxxxxxxx>
Cc: Miri Korenblit <miriam.rachel.korenblit@xxxxxxxxx>
Cc: Alexander Stein <alexander.stein@xxxxxxxxxxxxxxx>
Cc: Cryolitia PukNgae <cryolitia@xxxxxxxxxxxxx>
Cc: Jiaming Zhang <r772577952@xxxxxxxxx>
Cc: Will Porter <mrwillporter@xxxxxxxxx>
Cc: Cen Zhang <zzzccc427@xxxxxxxxx>
Cc: "Cássio Gabriel" <cassiogabrielcontato@xxxxxxxxx>
Cc: Rong Zhang <i@xxxxxxxx>
Cc: Arun Raghavan <arunr@xxxxxxxxxxxxxxxxx>
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: loongarch@xxxxxxxxxxxxxxx
Cc: linux-mips@xxxxxxxxxxxxxxx
Cc: linux-parisc@xxxxxxxxxxxxxxx
Cc: linux-edac@xxxxxxxxxxxxxxx
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: intel-xe@xxxxxxxxxxxxxxxxxxxxx
Cc: linux-input@xxxxxxxxxxxxxxx
Cc: linux-media@xxxxxxxxxxxxxxx
Cc: intel-wired-lan@xxxxxxxxxxxxxxxx
Cc: netdev@xxxxxxxxxxxxxxx
Cc: linux-wireless@xxxxxxxxxxxxxxx
Cc: brcm80211@xxxxxxxxxxxxxxx
Cc: brcm80211-dev-list.pdl@xxxxxxxxxxxx
Cc: devicetree@xxxxxxxxxxxxxxx
Cc: linux-samsung-soc@xxxxxxxxxxxxxxx
Cc: linux-gpio@xxxxxxxxxxxxxxx
Cc: linux-scsi@xxxxxxxxxxxxxxx
Cc: linux-nfs@xxxxxxxxxxxxxxx
Cc: devel@xxxxxxxxxxxxxxxxxx
Cc: linux-hardening@xxxxxxxxxxxxxxx
Cc: linux-sound@xxxxxxxxxxxxxxx
---
drivers/scsi/bfa/bfa_fcs.c | 49 ++++++++++----------------------------
1 file changed, 13 insertions(+), 36 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
index 7a4e0e8c7182..9fe0343c0b32 100644
--- a/drivers/scsi/bfa/bfa_fcs.c
+++ b/drivers/scsi/bfa/bfa_fcs.c
@@ -760,49 +760,26 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)

bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);

- /* Model name/number */
- strscpy(port_cfg->sym_name.symname, model,
- BFA_SYMNAME_MAXLEN);
- strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
- BFA_SYMNAME_MAXLEN);
-
- /* Driver Version */
- strlcat(port_cfg->sym_name.symname, driver_info->version,
- BFA_SYMNAME_MAXLEN);
- strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
- BFA_SYMNAME_MAXLEN);
-
- /* Host machine name */
- strlcat(port_cfg->sym_name.symname,
- driver_info->host_machine_name,
- BFA_SYMNAME_MAXLEN);
- strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
- BFA_SYMNAME_MAXLEN);
-
/*
* Host OS Info :
* If OS Patch Info is not there, do not truncate any bytes from the
* OS name string and instead copy the entire OS info string (64 bytes).
*/
if (driver_info->host_os_patch[0] == '\0') {
- strlcat(port_cfg->sym_name.symname,
- driver_info->host_os_name,
- BFA_SYMNAME_MAXLEN);
- strlcat(port_cfg->sym_name.symname,
- BFA_FCS_PORT_SYMBNAME_SEPARATOR,
- BFA_SYMNAME_MAXLEN);
+ snprintf(port_cfg->sym_name.symname, BFA_SYMNAME_MAXLEN,
+ "%s%s%s%s%s%s%s%s",
+ model, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
+ driver_info->version, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
+ driver_info->host_machine_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
+ driver_info->host_os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR);
} else {
- strlcat(port_cfg->sym_name.symname,
- driver_info->host_os_name,
- BFA_SYMNAME_MAXLEN);
- strlcat(port_cfg->sym_name.symname,
- BFA_FCS_PORT_SYMBNAME_SEPARATOR,
- BFA_SYMNAME_MAXLEN);
-
- /* Append host OS Patch Info */
- strlcat(port_cfg->sym_name.symname,
- driver_info->host_os_patch,
- BFA_SYMNAME_MAXLEN);
+ snprintf(port_cfg->sym_name.symname, BFA_SYMNAME_MAXLEN,
+ "%s%s%s%s%s%s%s%s%s",
+ model, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
+ driver_info->version, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
+ driver_info->host_machine_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
+ driver_info->host_os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
+ driver_info->host_os_patch);
}

/* null terminate */
--
2.55.0.1032.g73a4cd73de-goog