summaryrefslogtreecommitdiffstats
path: root/sys/scsi/scsi_base.c
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2020-09-05 14:21:52 +0000
committerkrw <krw@openbsd.org>2020-09-05 14:21:52 +0000
commit65e0582e53a009b2595e7004ffc6aea3874f6844 (patch)
tree871fe70a0936d6a9577f0577f708afa562715c50 /sys/scsi/scsi_base.c
parentAdd mpii(4). (diff)
downloadwireguard-openbsd-65e0582e53a009b2595e7004ffc6aea3874f6844.tar.xz
wireguard-openbsd-65e0582e53a009b2595e7004ffc6aea3874f6844.zip
Rename SID_INQUIRY_HDR (a.k.a. 5) to more explicit SID_SCSI2_HDRLEN and use it
to replace various uses of '5' when calculating the amount of data in the INQUIRY response. Matches up more naturally with SID_SCSI2_ALEN. Also use to fix SCSIDEBUG display of INQUIRY responses to show correct count of bytes received/available.
Diffstat (limited to 'sys/scsi/scsi_base.c')
-rw-r--r--sys/scsi/scsi_base.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index f582d5fb07c..00402e42be7 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.273 2020/09/01 12:17:53 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.274 2020/09/05 14:21:52 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -849,7 +849,7 @@ scsi_inquire(struct scsi_link *link, struct scsi_inquiry_data *inqbuf,
* information. This avoids problems with devices that choke trying to
* supply more.
*/
- bytes = 36;
+ bytes = SID_SCSI2_HDRLEN + SID_SCSI2_ALEN;
#ifdef SCSIDEBUG
again:
@@ -872,13 +872,14 @@ again:
#ifdef SCSIDEBUG
sc_print_addr(link);
- if (bytes > inqbuf->additional_length + 4)
- bytes = inqbuf->additional_length + 4;
+ if (bytes > SID_SCSI2_HDRLEN + inqbuf->additional_length)
+ bytes = SID_SCSI2_HDRLEN + inqbuf->additional_length;
printf("got %zu of %u bytes of inquiry data:\n",
- bytes, inqbuf->additional_length + 4);
+ bytes, SID_SCSI2_HDRLEN + inqbuf->additional_length);
scsi_show_mem((u_char *)inqbuf, bytes);
- if (bytes == 36 && bytes < inqbuf->additional_length + 4) {
- bytes = inqbuf->additional_length + 4;
+ if (bytes == SID_SCSI2_HDRLEN + SID_SCSI2_ALEN && bytes <
+ SID_SCSI2_HDRLEN + inqbuf->additional_length) {
+ bytes = SID_SCSI2_HDRLEN + inqbuf->additional_length;
if (bytes > sizeof(*inqbuf))
bytes = sizeof(*inqbuf);
goto again;