Skip to contentSkip to conversation

scsi: fnic: Remove unnecessary NUL-terminations

PATCH Applied Thorsten Blum 3 participants 4 messages Mar 14, 2025 – Mar 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: fnic: Remove unnecessary NUL-terminations

strscpy_pad() already NUL-terminates 'data' at the corresponding indexes. Remove any unnecessary NUL-terminations.

No functional changes intended.

---
 drivers/scsi/fnic/fdls_disc.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/scsi/fnic/fdls_disc.c +0 -3
index 11211c469583..7294645ed6d2 100644
@@ -1898,7 +1898,6 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)
 	if (fnic->subsys_desc_len >= FNIC_FDMI_MODEL_LEN)
 		fnic->subsys_desc_len = FNIC_FDMI_MODEL_LEN - 1;
 	strscpy_pad(data, fnic->subsys_desc, FNIC_FDMI_MODEL_LEN);
-	data[FNIC_FDMI_MODEL_LEN - 1] = 0;
 	fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_MODEL, FNIC_FDMI_MODEL_LEN,
 		data, &attr_off_bytes);
 
@@ -2061,7 +2060,6 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)
 	snprintf(tmp_data, FNIC_FDMI_OS_NAME_LEN - 1, "host%d",
 		 fnic->host->host_no);
 	strscpy_pad(data, tmp_data, FNIC_FDMI_OS_NAME_LEN);
-	data[FNIC_FDMI_OS_NAME_LEN - 1] = 0;
 	fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_OS_NAME,
 		FNIC_FDMI_OS_NAME_LEN, data, &attr_off_bytes);
 
@@ -2071,7 +2069,6 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)
 	sprintf(fc_host_system_hostname(fnic->host), "%s", utsname()->nodename);
 	strscpy_pad(data, fc_host_system_hostname(fnic->host),
 					FNIC_FDMI_HN_LEN);
-	data[FNIC_FDMI_HN_LEN - 1] = 0;
 	fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_HOST_NAME,
 		FNIC_FDMI_HN_LEN, data, &attr_off_bytes);
 
Signature · 1 line
2.48.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 40 lines · Thorsten Blum

strscpy_pad() already NUL-terminates 'data' at the corresponding indexes. Remove any unnecessary NUL-terminations.

No functional changes intended.

---
drivers/scsi/fnic/fdls_disc.c | 3 ---

1 file changed, 3 deletions(-)
drivers/scsi/fnic/fdls_disc.c +0 -4
index 11211c469583..7294645ed6d2 100644
@@ -1898,7 +1898,6 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)
 if (fnic->subsys_desc_len >= FNIC_FDMI_MODEL_LEN)
 fnic->subsys_desc_len = FNIC_FDMI_MODEL_LEN - 1;
 strscpy_pad(data, fnic->subsys_desc, FNIC_FDMI_MODEL_LEN);
-     data[FNIC_FDMI_MODEL_LEN - 1] = 0;
 fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_MODEL, FNIC_FDMI_MODEL_LEN,
 data, &attr_off_bytes);
 
@@ -2061,7 +2060,6 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)
 snprintf(tmp_data, FNIC_FDMI_OS_NAME_LEN - 1, "host%d",
 fnic->host->host_no);
 strscpy_pad(data, tmp_data, FNIC_FDMI_OS_NAME_LEN);
-     data[FNIC_FDMI_OS_NAME_LEN - 1] = 0;
 fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_OS_NAME,
 FNIC_FDMI_OS_NAME_LEN, data, &attr_off_bytes);
 
@@ -2071,7 +2069,6 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)
 sprintf(fc_host_system_hostname(fnic->host), "%s", utsname()->nodename);
 strscpy_pad(data, fc_host_system_hostname(fnic->host),
 FNIC_FDMI_HN_LEN);
-     data[FNIC_FDMI_HN_LEN - 1] = 0;
 fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_HOST_NAME,
 FNIC_FDMI_HN_LEN, data, &attr_off_bytes);
 
--
Quoted 3 lines

2.48.1

Looks good to me.

Regards,
Karan

#2 lore raw
In reply to Thorsten Blum

Thorsten,

Quoted 2 lines

strscpy_pad() already NUL-terminates 'data' at the corresponding indexes. Remove any unnecessary NUL-terminations.

Applied to 6.15/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering