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: [email protected]
Assisted-by: Gemini-3.5-Pro:20241215 [editor_update_file, 
make_kernel_build_single_file]
Signed-off-by: Bill Wendling <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: WANG Xuerui <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: [email protected]
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ian Abbott <[email protected]>
Cc: H Hartley Sweeten <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Matthew Brost <[email protected]>
Cc: "Thomas Hellström" <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Matthias Schwarzott <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Tony Nguyen <[email protected]>
Cc: Przemek Kitszel <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Saravana Kannan <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Sylwester Nawrocki <[email protected]>
Cc: Peter Griffin <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Anil Gurumurthy <[email protected]>
Cc: Sudarsana Kalluru <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: Trond Myklebust <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: Mike Marshall <[email protected]>
Cc: Martin Brandenburg <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Jiri Pirko <[email protected]>
Cc: Simon Horman <[email protected]>
Cc: Chuck Lever <[email protected]>
Cc: Jeff Layton <[email protected]>
Cc: NeilBrown <[email protected]>
Cc: Olga Kornievskaia <[email protected]>
Cc: Dai Ngo <[email protected]>
Cc: Tom Talpey <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Bill Wendling <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: "Mike Rapoport (Microsoft)" <[email protected]>
Cc: Kanglong Wang <[email protected]>
Cc: Tiezhu Yang <[email protected]>
Cc: Qiang Ma <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Pengpeng Hou <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Breno Leitao <[email protected]>
Cc: Thorsten Blum <[email protected]>
Cc: Harshit Mogalapalli <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Lyude Paul <[email protected]>
Cc: Ashutosh Desai <[email protected]>
Cc: Imre Deak <[email protected]>
Cc: Dmitry Baryshkov <[email protected]>
Cc: Johan Hovold <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: Miri Korenblit <[email protected]>
Cc: Alexander Stein <[email protected]>
Cc: Cryolitia PukNgae <[email protected]>
Cc: Jiaming Zhang <[email protected]>
Cc: Will Porter <[email protected]>
Cc: Cen Zhang <[email protected]>
Cc: "Cássio Gabriel" <[email protected]>
Cc: Rong Zhang <[email protected]>
Cc: Arun Raghavan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
 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

Reply via email to