Re: [PATCH 1/6] scsi: target: core: add support of RSOC command

kernel test robot
2022-07-19T10:08:53Z

Hi Dmitry,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on jejb-scsi/for-next linus/master v5.19-rc7 next-20220718]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Bogdanov/add-support-of-RSOC-command/20220718-200622
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: nios2-randconfig-s042-20220718 (https://download.01.org/0day-ci/archive/20220719/202207191727.tSUku1lU-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/dd5367ced3f2a2d631776343184cca65d8cfbed8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Dmitry-Bogdanov/add-support-of-RSOC-command/20220718-200622
git checkout dd5367ced3f2a2d631776343184cca65d8cfbed8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/target/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
>> drivers/target/target_core_spc.c:1459:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:1459:21: sparse: expected int ret
drivers/target/target_core_spc.c:1459:21: sparse: got restricted sense_reason_t
drivers/target/target_core_spc.c:1466:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:1466:21: sparse: expected int ret
drivers/target/target_core_spc.c:1466:21: sparse: got restricted sense_reason_t
drivers/target/target_core_spc.c:1478:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted sense_reason_t @@
drivers/target/target_core_spc.c:1478:21: sparse: expected int ret
drivers/target/target_core_spc.c:1478:21: sparse: got restricted sense_reason_t
>> drivers/target/target_core_spc.c:1504:16: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted sense_reason_t @@ got int ret @@
drivers/target/target_core_spc.c:1504:16: sparse: expected restricted sense_reason_t
drivers/target/target_core_spc.c:1504:16: sparse: got int ret

vim +1459 drivers/target/target_core_spc.c

1442
1443 static sense_reason_t
1444 spc_emulate_report_supp_op_codes(struct se_cmd *cmd)
1445 {
1446 int descr_num = ARRAY_SIZE(tcm_supported_opcodes);
1447 struct target_opcode_descriptor *descr = NULL;
1448 unsigned char *cdb = cmd->t_task_cdb;
1449 u8 rctd = (cdb[2] >> 7) & 0x1;
1450 unsigned char *buf = NULL;
1451 int response_length = 0;
1452 u8 opts = cdb[2] & 0x3;
1453 unsigned char *rbuf;
1454 int ret = 0;
1455 int i;
1456
1457 rbuf = transport_kmap_data_sg(cmd);
1458 if (cmd->data_length && !rbuf) {
> 1459 ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1460 goto out;
1461 }
1462
1463 if (opts == 0)
1464 response_length = 4 + (8 + rctd * 12) * descr_num;
1465 else {
1466 ret = spc_rsoc_get_descr(cmd, &descr);
1467 if (ret)
1468 goto out;
1469
1470 if (descr)
1471 response_length = 4 + descr->cdb_size + rctd * 12;
1472 else
1473 response_length = 2;
1474 }
1475
1476 buf = kzalloc(response_length, GFP_KERNEL);
1477 if (!buf) {
1478 ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1479 goto out;
1480 }
1481 response_length = 0;
1482
1483 if (opts == 0) {
1484 response_length += 4;
1485
1486 for (i = 0; i < ARRAY_SIZE(tcm_supported_opcodes); i++) {
1487 descr = tcm_supported_opcodes[i];
1488 response_length += spc_rsoc_encode_command_descriptor(
1489 &buf[response_length], rctd, descr);
1490 }
1491 put_unaligned_be32(response_length - 3, buf);
1492 } else {
1493 response_length = spc_rsoc_encode_one_command_descriptor(
1494 &buf[response_length], rctd, descr);
1495 }
1496
1497 memcpy(rbuf, buf, min_t(u32, response_length, cmd->data_length));
1498 out:
1499 kfree(buf);
1500 transport_kunmap_data_sg(cmd);
1501
1502 if (!ret)
1503 target_complete_cmd_with_length(cmd, SAM_STAT_GOOD, response_length);
> 1504 return ret;
1505 }
1506

--
0-DAY CI Kernel Test Service