diff options
| author | christos <christos@NetBSD.org> | 2016-05-02 19:18:29 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2016-05-02 19:18:29 +0000 |
| commit | d591b4e8741370bd42e79d22ed4da3f966edb669 (patch) | |
| tree | 569fca075f4a14393f3a043c914a43f8ba82b500 /sys/dev | |
| parent | 0da5af96a0e50d94b3caf3b0f7da1563aeb673af (diff) | |
move scsipi_strvis -> libkern:strnvisx()
change the prototype to match userland
fix sizes of strings passed to it
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ata/ld_ataraid.c | 16 | ||||
| -rw-r--r-- | sys/dev/ic/ahcisata_core.c | 15 | ||||
| -rw-r--r-- | sys/dev/ic/mpt_netbsd.c | 34 | ||||
| -rw-r--r-- | sys/dev/ic/mvsata.c | 14 | ||||
| -rw-r--r-- | sys/dev/ic/nvme.c | 58 | ||||
| -rw-r--r-- | sys/dev/ic/siisata.c | 15 | ||||
| -rw-r--r-- | sys/dev/pci/arcmsr.c | 27 | ||||
| -rw-r--r-- | sys/dev/pci/mpii.c | 18 | ||||
| -rw-r--r-- | sys/dev/scsipi/atapi_wdc.c | 17 | ||||
| -rw-r--r-- | sys/dev/scsipi/scsiconf.c | 13 | ||||
| -rw-r--r-- | sys/dev/scsipi/scsipiconf.c | 44 | ||||
| -rw-r--r-- | sys/dev/scsipi/scsipiconf.h | 3 | ||||
| -rw-r--r-- | sys/dev/usb/umass_scsipi.c | 13 |
13 files changed, 115 insertions, 172 deletions
diff --git a/sys/dev/ata/ld_ataraid.c b/sys/dev/ata/ld_ataraid.c index a2fff4c6b82..afed62ae8f0 100644 --- a/sys/dev/ata/ld_ataraid.c +++ b/sys/dev/ata/ld_ataraid.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld_ataraid.c,v 1.40 2015/04/13 16:33:24 riastradh Exp $ */ +/* $NetBSD: ld_ataraid.c,v 1.41 2016/05/02 19:18:29 christos Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.40 2015/04/13 16:33:24 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.41 2016/05/02 19:18:29 christos Exp $"); #include "bio.h" @@ -698,12 +698,12 @@ ld_ataraid_biodisk(struct ld_ataraid_softc *sc, struct bioc_disk *bd) strlcpy(bd->bd_procdev, device_xname(adi->adi_dev), sizeof(bd->bd_procdev)); - scsipi_strvis(serial, sizeof(serial), wd->sc_params.atap_serial, - sizeof(wd->sc_params.atap_serial)); - scsipi_strvis(model, sizeof(model), wd->sc_params.atap_model, - sizeof(wd->sc_params.atap_model)); - scsipi_strvis(rev, sizeof(rev), wd->sc_params.atap_revision, - sizeof(wd->sc_params.atap_revision)); + strnvisx(serial, sizeof(serial), wd->sc_params.atap_serial, + sizeof(wd->sc_params.atap_serial), VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(model, sizeof(model), wd->sc_params.atap_model, + sizeof(wd->sc_params.atap_model), VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(rev, sizeof(rev), wd->sc_params.atap_revision, + sizeof(wd->sc_params.atap_revision), VIS_TRIM|VIS_SAFE|VIS_OCTAL); snprintf(bd->bd_vendor, sizeof(bd->bd_vendor), "%s %s", model, rev); strlcpy(bd->bd_serial, serial, sizeof(bd->bd_serial)); diff --git a/sys/dev/ic/ahcisata_core.c b/sys/dev/ic/ahcisata_core.c index 78eea5e1db1..96970d6f44b 100644 --- a/sys/dev/ic/ahcisata_core.c +++ b/sys/dev/ic/ahcisata_core.c @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_core.c,v 1.55 2015/11/11 02:43:09 jakllsch Exp $ */ +/* $NetBSD: ahcisata_core.c,v 1.56 2016/05/02 19:18:29 christos Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.55 2015/11/11 02:43:09 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.56 2016/05/02 19:18:29 christos Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -1846,11 +1846,12 @@ ahci_atapi_probe_device(struct atapibus_softc *sc, int target) sa.sa_inqbuf.type = ATAPI_CFG_TYPE(id->atap_config); sa.sa_inqbuf.removable = id->atap_config & ATAPI_CFG_REMOV ? T_REMOV : T_FIXED; - scsipi_strvis((u_char *)model, 40, id->atap_model, 40); - scsipi_strvis((u_char *)serial_number, 20, id->atap_serial, - 20); - scsipi_strvis((u_char *)firmware_revision, 8, - id->atap_revision, 8); + strnvisx(model, sizeof(model), id->atap_model, 40, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(serial_number, sizeof(serial_number), id->atap_serial, + 20, VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(firmware_revision, sizeof(firmware_revision), + id->atap_revision, 8, VIS_TRIM|VIS_SAFE|VIS_OCTAL); sa.sa_inqbuf.vendor = model; sa.sa_inqbuf.product = serial_number; sa.sa_inqbuf.revision = firmware_revision; diff --git a/sys/dev/ic/mpt_netbsd.c b/sys/dev/ic/mpt_netbsd.c index 7f7c13bc91e..2a15d0d9c6a 100644 --- a/sys/dev/ic/mpt_netbsd.c +++ b/sys/dev/ic/mpt_netbsd.c @@ -1,4 +1,4 @@ -/* $NetBSD: mpt_netbsd.c,v 1.32 2015/07/22 08:33:51 hannken Exp $ */ +/* $NetBSD: mpt_netbsd.c,v 1.33 2016/05/02 19:18:29 christos Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.32 2015/07/22 08:33:51 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.33 2016/05/02 19:18:29 christos Exp $"); #include "bio.h" @@ -1857,12 +1857,15 @@ mpt_bio_ioctl_vol(mpt_softc_t *mpt, struct bioc_vol *bv) memset(&inqbuf, 0, sizeof(inqbuf)); if (scsipi_inquire(periph, &inqbuf, XS_CTL_DISCOVERY | XS_CTL_SILENT) == 0) { - scsipi_strvis(vendor, sizeof(vendor), - inqbuf.vendor, sizeof(inqbuf.vendor)); - scsipi_strvis(product, sizeof(product), - inqbuf.product, sizeof(inqbuf.product)); - scsipi_strvis(revision, sizeof(revision), - inqbuf.revision, sizeof(inqbuf.revision)); + strnvisx(vendor, sizeof(vendor), + inqbuf.vendor, sizeof(inqbuf.vendor), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(product, sizeof(product), + inqbuf.product, sizeof(inqbuf.product), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(revision, sizeof(revision), + inqbuf.revision, sizeof(inqbuf.revision), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); snprintf(bv->bv_vendor, sizeof(bv->bv_vendor), "%s %s %s", vendor, product, revision); @@ -1927,13 +1930,16 @@ mpt_bio_ioctl_disk_common(mpt_softc_t *mpt, struct bioc_disk *bd, if (phys == NULL) return; - scsipi_strvis(vendor_id, sizeof(vendor_id), - phys->InquiryData.VendorID, sizeof(phys->InquiryData.VendorID)); - scsipi_strvis(product_id, sizeof(product_id), - phys->InquiryData.ProductID, sizeof(phys->InquiryData.ProductID)); - scsipi_strvis(product_rev_level, sizeof(product_rev_level), + strnvisx(vendor_id, sizeof(vendor_id), + phys->InquiryData.VendorID, sizeof(phys->InquiryData.VendorID), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(product_id, sizeof(product_id), + phys->InquiryData.ProductID, sizeof(phys->InquiryData.ProductID), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(product_rev_level, sizeof(product_rev_level), phys->InquiryData.ProductRevLevel, - sizeof(phys->InquiryData.ProductRevLevel)); + sizeof(phys->InquiryData.ProductRevLevel), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); snprintf(bd->bd_vendor, sizeof(bd->bd_vendor), "%s %s %s", vendor_id, product_id, product_rev_level); diff --git a/sys/dev/ic/mvsata.c b/sys/dev/ic/mvsata.c index 32d5ad89deb..13d5d1c7417 100644 --- a/sys/dev/ic/mvsata.c +++ b/sys/dev/ic/mvsata.c @@ -1,4 +1,4 @@ -/* $NetBSD: mvsata.c,v 1.34 2015/01/02 19:42:07 christos Exp $ */ +/* $NetBSD: mvsata.c,v 1.35 2016/05/02 19:18:29 christos Exp $ */ /* * Copyright (c) 2008 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.34 2015/01/02 19:42:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35 2016/05/02 19:18:29 christos Exp $"); #include "opt_mvsata.h" @@ -888,10 +888,12 @@ mvsata_atapi_probe_device(struct atapibus_softc *sc, int target) sa.sa_inqbuf.type = ATAPI_CFG_TYPE(id->atap_config); sa.sa_inqbuf.removable = id->atap_config & ATAPI_CFG_REMOV ? T_REMOV : T_FIXED; - scsipi_strvis((u_char *)model, 40, id->atap_model, 40); - scsipi_strvis((u_char *)serial_number, 20, id->atap_serial, 20); - scsipi_strvis((u_char *)firmware_revision, 8, id->atap_revision, - 8); + strnvisx(model, sizeof(model), id->atap_model, 40, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(serial_number, sizeof(serial_number), id->atap_serial, + 20, VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(firmware_revision, sizeof(firmware_revision), + id->atap_revision, 8, VIS_TRIM|VIS_SAFE|VIS_OCTAL); sa.sa_inqbuf.vendor = model; sa.sa_inqbuf.product = serial_number; sa.sa_inqbuf.revision = firmware_revision; diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index e6fb3456053..3f8e0cb19ee 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -1,4 +1,4 @@ -/* $NetBSD: nvme.c,v 1.1 2016/05/01 10:21:02 nonaka Exp $ */ +/* $NetBSD: nvme.c,v 1.2 2016/05/02 19:18:29 christos Exp $ */ /* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */ /* @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.1 2016/05/01 10:21:02 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.2 2016/05/02 19:18:29 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -95,8 +95,6 @@ static void nvme_ns_sync_fill(struct nvme_queue *, struct nvme_ccb *, static void nvme_ns_sync_done(struct nvme_queue *, struct nvme_ccb *, struct nvme_cqe *); -static void nvme_strvis(u_char *, int, const u_char *, int); - #define nvme_read4(_s, _r) \ bus_space_read_4((_s)->sc_iot, (_s)->sc_ioh, (_r)) #define nvme_write4(_s, _r, _v) \ @@ -900,9 +898,12 @@ nvme_identify(struct nvme_softc *sc, u_int mps) identify = NVME_DMA_KVA(mem); - nvme_strvis(sn, sizeof(sn), identify->sn, sizeof(identify->sn)); - nvme_strvis(mn, sizeof(mn), identify->mn, sizeof(identify->mn)); - nvme_strvis(fr, sizeof(fr), identify->fr, sizeof(identify->fr)); + strnvisx(sn, sizeof(sn), (const char *)identify->sn, + sizeof(identify->sn), VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(mn, sizeof(mn), (const char *)identify->mn, + sizeof(identify->mn), VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(fr, sizeof(fr), (const char *)identify->fr, + sizeof(identify->fr), VIS_TRIM|VIS_SAFE|VIS_OCTAL); aprint_normal_dev(sc->sc_dev, "%s, firmware %s, serial %s\n", mn, fr, sn); @@ -1288,46 +1289,3 @@ nvme_dmamem_free(struct nvme_softc *sc, struct nvme_dmamem *ndm) bus_dmamap_destroy(sc->sc_dmat, ndm->ndm_map); kmem_free(ndm, sizeof(*ndm)); } - -/* - * Copy of sys/dev/scsipi/scsipiconf.c:scsipi_strvis() - */ -static void -nvme_strvis(u_char *dst, int dlen, const u_char *src, int slen) -{ - -#define STRVIS_ISWHITE(x) ((x) == ' ' || (x) == '\0' || (x) == (u_char)'\377') - /* Trim leading and trailing blanks and NULs. */ - while (slen > 0 && STRVIS_ISWHITE(src[0])) - ++src, --slen; - while (slen > 0 && STRVIS_ISWHITE(src[slen - 1])) - --slen; - - while (slen > 0) { - if (*src < 0x20 || *src >= 0x80) { - /* non-printable characters */ - dlen -= 4; - if (dlen < 1) - break; - *dst++ = '\\'; - *dst++ = ((*src & 0300) >> 6) + '0'; - *dst++ = ((*src & 0070) >> 3) + '0'; - *dst++ = ((*src & 0007) >> 0) + '0'; - } else if (*src == '\\') { - /* quote characters */ - dlen -= 2; - if (dlen < 1) - break; - *dst++ = '\\'; - *dst++ = '\\'; - } else { - /* normal characters */ - if (--dlen < 1) - break; - *dst++ = *src; - } - ++src, --slen; - } - - *dst++ = 0; -} diff --git a/sys/dev/ic/siisata.c b/sys/dev/ic/siisata.c index ea7150b1503..a90fa092b05 100644 --- a/sys/dev/ic/siisata.c +++ b/sys/dev/ic/siisata.c @@ -1,4 +1,4 @@ -/* $NetBSD: siisata.c,v 1.27 2013/08/08 17:38:56 bouyer Exp $ */ +/* $NetBSD: siisata.c,v 1.28 2016/05/02 19:18:29 christos Exp $ */ /* from ahcisata_core.c */ @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.27 2013/08/08 17:38:56 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.28 2016/05/02 19:18:29 christos Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -1459,11 +1459,12 @@ siisata_atapi_probe_device(struct atapibus_softc *sc, int target) sa.sa_inqbuf.type = ATAPI_CFG_TYPE(id->atap_config); sa.sa_inqbuf.removable = id->atap_config & ATAPI_CFG_REMOV ? T_REMOV : T_FIXED; - scsipi_strvis((u_char *)model, 40, id->atap_model, 40); - scsipi_strvis((u_char *)serial_number, 20, - id->atap_serial, 20); - scsipi_strvis((u_char *)firmware_revision, 8, - id->atap_revision, 8); + strnvisx(model, sizeof(model), id->atap_model, 40, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(serial_number, sizeof(serial_number), + id->atap_serial, 20, VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(firmware_revision, sizeof(firmware_revision), + id->atap_revision, 8, VIS_TRIM|VIS_SAFE|VIS_OCTAL); sa.sa_inqbuf.vendor = model; sa.sa_inqbuf.product = serial_number; sa.sa_inqbuf.revision = firmware_revision; diff --git a/sys/dev/pci/arcmsr.c b/sys/dev/pci/arcmsr.c index 05cabeba77d..5136a8e3f80 100644 --- a/sys/dev/pci/arcmsr.c +++ b/sys/dev/pci/arcmsr.c @@ -1,4 +1,4 @@ -/* $NetBSD: arcmsr.c,v 1.32 2015/03/12 15:33:10 christos Exp $ */ +/* $NetBSD: arcmsr.c,v 1.33 2016/05/02 19:18:29 christos Exp $ */ /* $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */ /* @@ -21,7 +21,7 @@ #include "bio.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.32 2015/03/12 15:33:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.33 2016/05/02 19:18:29 christos Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -635,15 +635,18 @@ arc_query_firmware(device_t self) DNPRINTF(ARC_D_INIT, "%s: sata_ports: %d\n", device_xname(self), htole32(fwinfo.sata_ports)); - scsipi_strvis(string, 81, fwinfo.vendor, sizeof(fwinfo.vendor)); + strnvisx(string, sizeof(string), fwinfo.vendor, sizeof(fwinfo.vendor), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); DNPRINTF(ARC_D_INIT, "%s: vendor: \"%s\"\n", device_xname(self), string); - scsipi_strvis(string, 17, fwinfo.model, sizeof(fwinfo.model)); + strnvisx(string, sizeof(string), fwinfo.model, sizeof(fwinfo.model), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); aprint_normal_dev(self, "Areca %s Host Adapter RAID controller\n", string); - scsipi_strvis(string, 33, fwinfo.fw_version, sizeof(fwinfo.fw_version)); + strnvisx(string, sizeof(string), fwinfo.fw_version, + sizeof(fwinfo.fw_version), VIS_TRIM|VIS_SAFE|VIS_OCTAL); DNPRINTF(ARC_D_INIT, "%s: version: \"%s\"\n", device_xname(self), string); @@ -1328,8 +1331,8 @@ arc_bio_vol(struct arc_softc *sc, struct bioc_vol *bv) bv->bv_nodisk = volinfo->member_disks; bv->bv_stripe_size = volinfo->stripe_size / 2; snprintf(bv->bv_dev, sizeof(bv->bv_dev), "sd%d", bv->bv_volid); - scsipi_strvis(bv->bv_vendor, sizeof(bv->bv_vendor), volinfo->set_name, - sizeof(volinfo->set_name)); + strnvisx(bv->bv_vendor, sizeof(bv->bv_vendor), volinfo->set_name, + sizeof(volinfo->set_name), VIS_TRIM|VIS_SAFE|VIS_OCTAL); out: kmem_free(volinfo, sizeof(*volinfo)); @@ -1417,10 +1420,12 @@ arc_bio_disk_filldata(struct arc_softc *sc, struct bioc_disk *bd, blocks += (uint64_t)htole32(diskinfo->capacity); bd->bd_size = blocks * ARC_BLOCKSIZE; /* XXX */ - scsipi_strvis(model, 81, diskinfo->model, sizeof(diskinfo->model)); - scsipi_strvis(serial, 41, diskinfo->serial, sizeof(diskinfo->serial)); - scsipi_strvis(rev, 17, diskinfo->firmware_rev, - sizeof(diskinfo->firmware_rev)); + strnvisx(model, sizeof(model), diskinfo->model, + sizeof(diskinfo->model), VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(serial, sizeof(serial), diskinfo->serial, + sizeof(diskinfo->serial), VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(rev, sizeof(rev), diskinfo->firmware_rev, + sizeof(diskinfo->firmware_rev), VIS_TRIM|VIS_SAFE|VIS_OCTAL); snprintf(bd->bd_vendor, sizeof(bd->bd_vendor), "%s %s", model, rev); strlcpy(bd->bd_serial, serial, sizeof(bd->bd_serial)); diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c index 847fce9b4d7..2039d4ad08f 100644 --- a/sys/dev/pci/mpii.c +++ b/sys/dev/pci/mpii.c @@ -1,4 +1,4 @@ -/* $NetBSD: mpii.c,v 1.7 2016/02/08 16:27:51 christos Exp $ */ +/* $NetBSD: mpii.c,v 1.8 2016/05/02 19:18:29 christos Exp $ */ /* OpenBSD: mpii.c,v 1.51 2012/04/11 13:29:14 naddy Exp */ /* * Copyright (c) 2010 Mike Belopuhov <mkb@crypt.org.ru> @@ -20,7 +20,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.7 2016/02/08 16:27:51 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8 2016/05/02 19:18:29 christos Exp $"); #include "bio.h" @@ -5398,14 +5398,16 @@ mpii_bio_disk(struct mpii_softc *sc, struct bioc_disk *bd, u_int8_t dn) bd->bd_size = le64toh(ppg->dev_max_lba) * le16toh(ppg->block_size); - scsipi_strvis(bd->bd_vendor, sizeof(bd->bd_vendor), - ppg->vendor_id, sizeof(ppg->vendor_id)); + strnvisx(bd->bd_vendor, sizeof(bd->bd_vendor), + ppg->vendor_id, sizeof(ppg->vendor_id), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); len = strlen(bd->bd_vendor); bd->bd_vendor[len] = ' '; - scsipi_strvis(&bd->bd_vendor[len + 1], sizeof(ppg->vendor_id) - len - 1, - ppg->product_id, sizeof(ppg->product_id)); - scsipi_strvis(bd->bd_serial, sizeof(bd->bd_serial), - ppg->serial, sizeof(ppg->serial)); + strnvisx(&bd->bd_vendor[len + 1], sizeof(ppg->vendor_id) - len - 1, + ppg->product_id, sizeof(ppg->product_id), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(bd->bd_serial, sizeof(bd->bd_serial), + ppg->serial, sizeof(ppg->serial), VIS_TRIM|VIS_SAFE|VIS_OCTAL); free(ppg, M_TEMP); return (0); diff --git a/sys/dev/scsipi/atapi_wdc.c b/sys/dev/scsipi/atapi_wdc.c index f981dde597d..4bb472fc35f 100644 --- a/sys/dev/scsipi/atapi_wdc.c +++ b/sys/dev/scsipi/atapi_wdc.c @@ -1,4 +1,4 @@ -/* $NetBSD: atapi_wdc.c,v 1.121 2016/03/20 10:29:12 tsutsui Exp $ */ +/* $NetBSD: atapi_wdc.c,v 1.122 2016/05/02 19:18:29 christos Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.121 2016/03/20 10:29:12 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.122 2016/05/02 19:18:29 christos Exp $"); #ifndef ATADEBUG #define ATADEBUG @@ -298,11 +298,14 @@ wdc_atapi_probe_device(struct atapibus_softc *sc, int target) sa.sa_inqbuf.type = ATAPI_CFG_TYPE(id->atap_config); sa.sa_inqbuf.removable = id->atap_config & ATAPI_CFG_REMOV ? T_REMOV : T_FIXED; - scsipi_strvis((u_char *)model, 40, id->atap_model, 40); - scsipi_strvis((u_char *)serial_number, 20, id->atap_serial, - 20); - scsipi_strvis((u_char *)firmware_revision, 8, - id->atap_revision, 8); + strnvisx(model, sizeof(model), id->atap_model, + sizeof(id->atap_model), VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(serial_number, sizeof(serial_number), + id->atap_serial, sizeof(id->atap_serial), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(firmware_revision, sizeof(firmware_revision), + id->atap_revision, sizeof(id->atap_revision), + VIS_TRIM|VIS_SAFE|VIS_OCTAL); sa.sa_inqbuf.vendor = model; sa.sa_inqbuf.product = serial_number; sa.sa_inqbuf.revision = firmware_revision; diff --git a/sys/dev/scsipi/scsiconf.c b/sys/dev/scsipi/scsiconf.c index 2fa75f85f35..8efa185f2ef 100644 --- a/sys/dev/scsipi/scsiconf.c +++ b/sys/dev/scsipi/scsiconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsiconf.c,v 1.273 2014/07/25 08:10:38 dholland Exp $ */ +/* $NetBSD: scsiconf.c,v 1.274 2016/05/02 19:18:29 christos Exp $ */ /*- * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.273 2014/07/25 08:10:38 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.274 2016/05/02 19:18:29 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -493,9 +493,12 @@ scsibusprint(void *aux, const char *pnp) dtype = scsipi_dtype(type); - scsipi_strvis(vendor, 33, inqbuf->vendor, 8); - scsipi_strvis(product, 65, inqbuf->product, 16); - scsipi_strvis(revision, 17, inqbuf->revision, 4); + strnvisx(vendor, sizeof(vendor), inqbuf->vendor, 8, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(product, sizeof(product), inqbuf->product, 16, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(revision, sizeof(revision), inqbuf->revision, 4, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); aprint_normal(" target %d lun %d: <%s, %s, %s> %s %s", target, lun, vendor, product, revision, dtype, diff --git a/sys/dev/scsipi/scsipiconf.c b/sys/dev/scsipi/scsipiconf.c index 6c43f380cff..cebab06e7c9 100644 --- a/sys/dev/scsipi/scsipiconf.c +++ b/sys/dev/scsipi/scsipiconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsipiconf.c,v 1.40 2010/08/21 13:18:36 pgoyette Exp $ */ +/* $NetBSD: scsipiconf.c,v 1.41 2016/05/02 19:18:29 christos Exp $ */ /*- * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: scsipiconf.c,v 1.40 2010/08/21 13:18:36 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsipiconf.c,v 1.41 2016/05/02 19:18:29 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -61,7 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: scsipiconf.c,v 1.40 2010/08/21 13:18:36 pgoyette Exp #include <dev/scsipi/scsipiconf.h> #include <dev/scsipi/scsipi_base.h> -#define STRVIS_ISWHITE(x) ((x) == ' ' || (x) == '\0' || (x) == (u_char)'\377') /* Function pointers and stub routines for scsiverbose module */ int (*scsipi_print_sense)(struct scsipi_xfer *, int) = scsipi_print_sense_stub; @@ -256,42 +255,3 @@ scsipi_dtype(int type) } return (dtype); } - -void -scsipi_strvis(u_char *dst, int dlen, const u_char *src, int slen) -{ - - /* Trim leading and trailing blanks and NULs. */ - while (slen > 0 && STRVIS_ISWHITE(src[0])) - ++src, --slen; - while (slen > 0 && STRVIS_ISWHITE(src[slen - 1])) - --slen; - - while (slen > 0) { - if (*src < 0x20 || *src >= 0x80) { - /* non-printable characters */ - dlen -= 4; - if (dlen < 1) - break; - *dst++ = '\\'; - *dst++ = ((*src & 0300) >> 6) + '0'; - *dst++ = ((*src & 0070) >> 3) + '0'; - *dst++ = ((*src & 0007) >> 0) + '0'; - } else if (*src == '\\') { - /* quote characters */ - dlen -= 2; - if (dlen < 1) - break; - *dst++ = '\\'; - *dst++ = '\\'; - } else { - /* normal characters */ - if (--dlen < 1) - break; - *dst++ = *src; - } - ++src, --slen; - } - - *dst++ = 0; -} diff --git a/sys/dev/scsipi/scsipiconf.h b/sys/dev/scsipi/scsipiconf.h index 2933d2d11eb..5c6b14d101b 100644 --- a/sys/dev/scsipi/scsipiconf.h +++ b/sys/dev/scsipi/scsipiconf.h @@ -1,4 +1,4 @@ -/* $NetBSD: scsipiconf.h,v 1.122 2014/07/13 17:12:23 dholland Exp $ */ +/* $NetBSD: scsipiconf.h,v 1.123 2016/05/02 19:18:29 christos Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc. @@ -642,7 +642,6 @@ void scsipi_create_completion_thread(void *); const void *scsipi_inqmatch(struct scsipi_inquiry_pattern *, const void *, size_t, size_t, int *); const char *scsipi_dtype(int); -void scsipi_strvis(u_char *, int, const u_char *, int); int scsipi_execute_xs(struct scsipi_xfer *); int scsipi_test_unit_ready(struct scsipi_periph *, int); int scsipi_prevent(struct scsipi_periph *, int, int); diff --git a/sys/dev/usb/umass_scsipi.c b/sys/dev/usb/umass_scsipi.c index 68ad318df87..613d4dceabb 100644 --- a/sys/dev/usb/umass_scsipi.c +++ b/sys/dev/usb/umass_scsipi.c @@ -1,4 +1,4 @@ -/* $NetBSD: umass_scsipi.c,v 1.50 2016/04/23 10:15:32 skrll Exp $ */ +/* $NetBSD: umass_scsipi.c,v 1.51 2016/05/02 19:18:29 christos Exp $ */ /* * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.50 2016/04/23 10:15:32 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.51 2016/05/02 19:18:29 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -555,9 +555,12 @@ umass_atapi_probe_device(struct atapibus_softc *atapi, int target) return; } - scsipi_strvis(vendor, 33, inqbuf.vendor, 8); - scsipi_strvis(product, 65, inqbuf.product, 16); - scsipi_strvis(revision, 17, inqbuf.revision, 4); + strnvisx(vendor, sizeof(vendor), inqbuf.vendor, 8, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(product, sizeof(product), inqbuf.product, 16, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); + strnvisx(revision, sizeof(revision), inqbuf.revision, 4, + VIS_TRIM|VIS_SAFE|VIS_OCTAL); sa.sa_periph = periph; sa.sa_inqbuf.type = inqbuf.device; |
