Re: [PATCH] scsi: libfc: replace deprecated strncpy with memcpy

From: kernel test robot
Date: Thu Nov 02 2023 - 11:04:12 EST


Hi Justin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on ffc253263a1375a65fa6c9f62a893e9767fbebfa]

url: https://github.com/intel-lab-lkp/linux/commits/Justin-Stitt/scsi-libfc-replace-deprecated-strncpy-with-memcpy/20231031-063815
base: ffc253263a1375a65fa6c9f62a893e9767fbebfa
patch link: https://lore.kernel.org/r/20231030-strncpy-drivers-scsi-libfc-fc_encode-h-v1-1-c08c2be6befa%40google.com
patch subject: [PATCH] scsi: libfc: replace deprecated strncpy with memcpy
config: s390-defconfig (https://download.01.org/0day-ci/archive/20231102/202311022256.mWiYJshd-lkp@xxxxxxxxx/config)
compiler: s390-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231102/202311022256.mWiYJshd-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311022256.mWiYJshd-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In function 'zfcp_fc_gspn',
inlined from 'zfcp_fc_sym_name_update' at drivers/s390/scsi/zfcp_fc.c:951:8:
>> drivers/s390/scsi/zfcp_fc.c:877:15: warning: 'strstr' argument 1 declared attribute 'nonstring' [-Wstringop-overread]
877 | !(strstr(gspn_rsp->gspn.fp_name, devno)))
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/scsi/libfc.h:21,
from drivers/s390/scsi/zfcp_fc.c:19:
include/uapi/scsi/fc/fc_ns.h: In function 'zfcp_fc_sym_name_update':
include/uapi/scsi/fc/fc_ns.h:148:17: note: argument 'fp_name' declared here
148 | char fp_name[] __nonstring;
| ^~~~~~~


vim +877 drivers/s390/scsi/zfcp_fc.c

cc8c282963bd25 Swen Schillig 2008-06-10 844
038d9446a9e601 Christof Schmitt 2011-02-22 845 static int zfcp_fc_gspn(struct zfcp_adapter *adapter,
038d9446a9e601 Christof Schmitt 2011-02-22 846 struct zfcp_fc_req *fc_req)
038d9446a9e601 Christof Schmitt 2011-02-22 847 {
038d9446a9e601 Christof Schmitt 2011-02-22 848 DECLARE_COMPLETION_ONSTACK(completion);
038d9446a9e601 Christof Schmitt 2011-02-22 849 char devno[] = "DEVNO:";
038d9446a9e601 Christof Schmitt 2011-02-22 850 struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els;
038d9446a9e601 Christof Schmitt 2011-02-22 851 struct zfcp_fc_gspn_req *gspn_req = &fc_req->u.gspn.req;
038d9446a9e601 Christof Schmitt 2011-02-22 852 struct zfcp_fc_gspn_rsp *gspn_rsp = &fc_req->u.gspn.rsp;
038d9446a9e601 Christof Schmitt 2011-02-22 853 int ret;
038d9446a9e601 Christof Schmitt 2011-02-22 854
038d9446a9e601 Christof Schmitt 2011-02-22 855 zfcp_fc_ct_ns_init(&gspn_req->ct_hdr, FC_NS_GSPN_ID,
038d9446a9e601 Christof Schmitt 2011-02-22 856 FC_SYMBOLIC_NAME_SIZE);
038d9446a9e601 Christof Schmitt 2011-02-22 857 hton24(gspn_req->gspn.fp_fid, fc_host_port_id(adapter->scsi_host));
038d9446a9e601 Christof Schmitt 2011-02-22 858
038d9446a9e601 Christof Schmitt 2011-02-22 859 sg_init_one(&fc_req->sg_req, gspn_req, sizeof(*gspn_req));
038d9446a9e601 Christof Schmitt 2011-02-22 860 sg_init_one(&fc_req->sg_rsp, gspn_rsp, sizeof(*gspn_rsp));
038d9446a9e601 Christof Schmitt 2011-02-22 861
038d9446a9e601 Christof Schmitt 2011-02-22 862 ct_els->handler = zfcp_fc_complete;
038d9446a9e601 Christof Schmitt 2011-02-22 863 ct_els->handler_data = &completion;
038d9446a9e601 Christof Schmitt 2011-02-22 864 ct_els->req = &fc_req->sg_req;
038d9446a9e601 Christof Schmitt 2011-02-22 865 ct_els->resp = &fc_req->sg_rsp;
038d9446a9e601 Christof Schmitt 2011-02-22 866
038d9446a9e601 Christof Schmitt 2011-02-22 867 ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL,
038d9446a9e601 Christof Schmitt 2011-02-22 868 ZFCP_FC_CTELS_TMO);
038d9446a9e601 Christof Schmitt 2011-02-22 869 if (ret)
038d9446a9e601 Christof Schmitt 2011-02-22 870 return ret;
038d9446a9e601 Christof Schmitt 2011-02-22 871
038d9446a9e601 Christof Schmitt 2011-02-22 872 wait_for_completion(&completion);
038d9446a9e601 Christof Schmitt 2011-02-22 873 if (ct_els->status)
038d9446a9e601 Christof Schmitt 2011-02-22 874 return ct_els->status;
038d9446a9e601 Christof Schmitt 2011-02-22 875
038d9446a9e601 Christof Schmitt 2011-02-22 876 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_NPIV &&
038d9446a9e601 Christof Schmitt 2011-02-22 @877 !(strstr(gspn_rsp->gspn.fp_name, devno)))
038d9446a9e601 Christof Schmitt 2011-02-22 878 snprintf(fc_host_symbolic_name(adapter->scsi_host),
038d9446a9e601 Christof Schmitt 2011-02-22 879 FC_SYMBOLIC_NAME_SIZE, "%s%s %s NAME: %s",
038d9446a9e601 Christof Schmitt 2011-02-22 880 gspn_rsp->gspn.fp_name, devno,
038d9446a9e601 Christof Schmitt 2011-02-22 881 dev_name(&adapter->ccw_device->dev),
038d9446a9e601 Christof Schmitt 2011-02-22 882 init_utsname()->nodename);
038d9446a9e601 Christof Schmitt 2011-02-22 883 else
820109fb11f24b Wolfram Sang 2022-08-18 884 strscpy(fc_host_symbolic_name(adapter->scsi_host),
038d9446a9e601 Christof Schmitt 2011-02-22 885 gspn_rsp->gspn.fp_name, FC_SYMBOLIC_NAME_SIZE);
038d9446a9e601 Christof Schmitt 2011-02-22 886
038d9446a9e601 Christof Schmitt 2011-02-22 887 return 0;
038d9446a9e601 Christof Schmitt 2011-02-22 888 }
038d9446a9e601 Christof Schmitt 2011-02-22 889

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki