diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_attr.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_attr.c | 63 |
1 files changed, 25 insertions, 38 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 77e1b2911cb4..76c3434f8976 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2004-2016 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * @@ -1905,8 +1905,7 @@ lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr, goto out_free_rdp; } - strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16); - chbuf[16] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16); len = scnprintf(buf, PAGE_SIZE - len, "VendorName:\t%s\n", chbuf); len += scnprintf(buf + len, PAGE_SIZE - len, @@ -1914,17 +1913,13 @@ lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr, (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI], (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 1], (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 2]); - strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16); - chbuf[16] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16); len += scnprintf(buf + len, PAGE_SIZE - len, "VendorPN:\t%s\n", chbuf); - strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16); - chbuf[16] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16); len += scnprintf(buf + len, PAGE_SIZE - len, "VendorSN:\t%s\n", chbuf); - strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4); - chbuf[4] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4); len += scnprintf(buf + len, PAGE_SIZE - len, "VendorRev:\t%s\n", chbuf); - strncpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8); - chbuf[8] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8); len += scnprintf(buf + len, PAGE_SIZE - len, "DateCode:\t%s\n", chbuf); len += scnprintf(buf + len, PAGE_SIZE - len, "Identifier:\t%xh\n", (uint8_t)rdp_context->page_a0[SSF_IDENTIFIER]); @@ -1941,33 +1936,25 @@ lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr, &rdp_context->page_a0[SSF_TRANSCEIVER_CODE_B7]; len += scnprintf(buf + len, PAGE_SIZE - len, "Speeds: \t"); - if (*(uint8_t *)trasn_code_byte7 == 0) { - len += scnprintf(buf + len, PAGE_SIZE - len, - "Unknown\n"); - } else { - if (trasn_code_byte7->fc_sp_100MB) - len += scnprintf(buf + len, PAGE_SIZE - len, - "1 "); - if (trasn_code_byte7->fc_sp_200mb) - len += scnprintf(buf + len, PAGE_SIZE - len, - "2 "); - if (trasn_code_byte7->fc_sp_400MB) - len += scnprintf(buf + len, PAGE_SIZE - len, - "4 "); - if (trasn_code_byte7->fc_sp_800MB) - len += scnprintf(buf + len, PAGE_SIZE - len, - "8 "); - if (trasn_code_byte7->fc_sp_1600MB) - len += scnprintf(buf + len, PAGE_SIZE - len, - "16 "); - if (trasn_code_byte7->fc_sp_3200MB) - len += scnprintf(buf + len, PAGE_SIZE - len, - "32 "); - if (trasn_code_byte7->speed_chk_ecc) - len += scnprintf(buf + len, PAGE_SIZE - len, - "64 "); - len += scnprintf(buf + len, PAGE_SIZE - len, "GB\n"); - } + if (*(uint8_t *)trasn_code_byte7 == 0) { + len += scnprintf(buf + len, PAGE_SIZE - len, "Unknown\n"); + } else { + if (trasn_code_byte7->fc_sp_100MB) + len += scnprintf(buf + len, PAGE_SIZE - len, "1 "); + if (trasn_code_byte7->fc_sp_200mb) + len += scnprintf(buf + len, PAGE_SIZE - len, "2 "); + if (trasn_code_byte7->fc_sp_400MB) + len += scnprintf(buf + len, PAGE_SIZE - len, "4 "); + if (trasn_code_byte7->fc_sp_800MB) + len += scnprintf(buf + len, PAGE_SIZE - len, "8 "); + if (trasn_code_byte7->fc_sp_1600MB) + len += scnprintf(buf + len, PAGE_SIZE - len, "16 "); + if (trasn_code_byte7->fc_sp_3200MB) + len += scnprintf(buf + len, PAGE_SIZE - len, "32 "); + if (trasn_code_byte7->speed_chk_ecc) + len += scnprintf(buf + len, PAGE_SIZE - len, "64 "); + len += scnprintf(buf + len, PAGE_SIZE - len, "GB\n"); + } temperature = (rdp_context->page_a2[SFF_TEMPERATURE_B1] << 8 | rdp_context->page_a2[SFF_TEMPERATURE_B0]); vcc = (rdp_context->page_a2[SFF_VCC_B1] << 8 | |