* [hare-scsi-devel:scsi-result-rework 8/146] drivers/scsi/sg.c:501:12: warning: address of array 'srp->sense_b' will always evaluate to 'true'
@ 2021-04-21 21:38 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-04-21 21:38 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 6216 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/hare/scsi-devel.git scsi-result-rework
head: 19720ea7b22b443a182646eef7edc36e32e7b515
commit: 650e66d86e623824cc550f1b8411951116a6b6ea [8/146] scsi: Kill DRIVER_SENSE
config: x86_64-randconfig-a016-20210421 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project d87b9b81ccb95217181ce75515c6c68bbb408ca4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/hare/scsi-devel.git/commit/?id=650e66d86e623824cc550f1b8411951116a6b6ea
git remote add hare-scsi-devel https://git.kernel.org/pub/scm/linux/kernel/git/hare/scsi-devel.git
git fetch --no-tags hare-scsi-devel scsi-result-rework
git checkout 650e66d86e623824cc550f1b8411951116a6b6ea
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> drivers/scsi/sg.c:501:12: warning: address of array 'srp->sense_b' will always evaluate to 'true' [-Wpointer-bool-conversion]
(srp->sense_b && (srp->sense_b[0] & 0x70) == 0x70)) {
~~~~~^~~~~~~ ~~
drivers/scsi/sg.c:579:13: warning: address of array 'srp->sense_b' will always evaluate to 'true' [-Wpointer-bool-conversion]
(srp->sense_b && (srp->sense_b[0] & 0x70) == 0x70)) {
~~~~~^~~~~~~ ~~
2 warnings generated.
vim +501 drivers/scsi/sg.c
439
440 static ssize_t
441 sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
442 {
443 Sg_device *sdp;
444 Sg_fd *sfp;
445 Sg_request *srp;
446 int req_pack_id = -1;
447 sg_io_hdr_t *hp;
448 struct sg_header *old_hdr;
449 int retval;
450
451 /*
452 * This could cause a response to be stranded. Close the associated
453 * file descriptor to free up any resources being held.
454 */
455 retval = sg_check_file_access(filp, __func__);
456 if (retval)
457 return retval;
458
459 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
460 return -ENXIO;
461 SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
462 "sg_read: count=%d\n", (int) count));
463
464 if (sfp->force_packid)
465 retval = get_sg_io_pack_id(&req_pack_id, buf, count);
466 if (retval)
467 return retval;
468
469 srp = sg_get_rq_mark(sfp, req_pack_id);
470 if (!srp) { /* now wait on packet to arrive */
471 if (atomic_read(&sdp->detaching))
472 return -ENODEV;
473 if (filp->f_flags & O_NONBLOCK)
474 return -EAGAIN;
475 retval = wait_event_interruptible(sfp->read_wait,
476 (atomic_read(&sdp->detaching) ||
477 (srp = sg_get_rq_mark(sfp, req_pack_id))));
478 if (atomic_read(&sdp->detaching))
479 return -ENODEV;
480 if (retval)
481 /* -ERESTARTSYS as signal hit process */
482 return retval;
483 }
484 if (srp->header.interface_id != '\0')
485 return sg_new_read(sfp, buf, count, srp);
486
487 hp = &srp->header;
488 old_hdr = kzalloc(SZ_SG_HEADER, GFP_KERNEL);
489 if (!old_hdr)
490 return -ENOMEM;
491
492 old_hdr->reply_len = (int) hp->timeout;
493 old_hdr->pack_len = old_hdr->reply_len; /* old, strange behaviour */
494 old_hdr->pack_id = hp->pack_id;
495 old_hdr->twelve_byte =
496 ((srp->data.cmd_opcode >= 0xc0) && (12 == hp->cmd_len)) ? 1 : 0;
497 old_hdr->target_status = hp->masked_status;
498 old_hdr->host_status = hp->host_status;
499 old_hdr->driver_status = hp->driver_status;
500 if ((CHECK_CONDITION & hp->masked_status) ||
> 501 (srp->sense_b && (srp->sense_b[0] & 0x70) == 0x70)) {
502 old_hdr->driver_status |= DRIVER_SENSE;
503 memcpy(old_hdr->sense_buffer, srp->sense_b,
504 sizeof (old_hdr->sense_buffer));
505 }
506 switch (hp->host_status) {
507 /* This setup of 'result' is for backward compatibility and is best
508 ignored by the user who should use target, host + driver status */
509 case DID_OK:
510 case DID_PASSTHROUGH:
511 case DID_SOFT_ERROR:
512 old_hdr->result = 0;
513 break;
514 case DID_NO_CONNECT:
515 case DID_BUS_BUSY:
516 case DID_TIME_OUT:
517 old_hdr->result = EBUSY;
518 break;
519 case DID_BAD_TARGET:
520 case DID_ABORT:
521 case DID_PARITY:
522 case DID_RESET:
523 case DID_BAD_INTR:
524 old_hdr->result = EIO;
525 break;
526 case DID_ERROR:
527 old_hdr->result = (srp->sense_b[0] == 0 &&
528 hp->masked_status == GOOD) ? 0 : EIO;
529 break;
530 default:
531 old_hdr->result = EIO;
532 break;
533 }
534
535 /* Now copy the result back to the user buffer. */
536 if (count >= SZ_SG_HEADER) {
537 if (copy_to_user(buf, old_hdr, SZ_SG_HEADER)) {
538 retval = -EFAULT;
539 goto free_old_hdr;
540 }
541 buf += SZ_SG_HEADER;
542 if (count > old_hdr->reply_len)
543 count = old_hdr->reply_len;
544 if (count > SZ_SG_HEADER) {
545 if (sg_read_oxfer(srp, buf, count - SZ_SG_HEADER)) {
546 retval = -EFAULT;
547 goto free_old_hdr;
548 }
549 }
550 } else
551 count = (old_hdr->result == 0) ? 0 : -EIO;
552 sg_finish_rem_req(srp);
553 sg_remove_request(sfp, srp);
554 retval = count;
555 free_old_hdr:
556 kfree(old_hdr);
557 return retval;
558 }
559
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34542 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-21 21:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-21 21:38 [hare-scsi-devel:scsi-result-rework 8/146] drivers/scsi/sg.c:501:12: warning: address of array 'srp->sense_b' will always evaluate to 'true' kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.