From: matthew Date: Thu, 22 Jul 2010 15:59:46 +0000 (+0000) Subject: Fix a few more scsi_scsi_cmd() removal regressions, caught by X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d1444a802099883b13e812c335a799805ab43bcc;p=openbsd Fix a few more scsi_scsi_cmd() removal regressions, caught by -Wuninitialized. Silly typo in my first diff noticed by oga@ and krw@; ok krw@ --- diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index a6423ad9f5d..b2c307b1d5a 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.177 2010/07/22 04:54:24 matthew Exp $ */ +/* $OpenBSD: cd.c,v 1.178 2010/07/22 15:59:46 matthew Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -1590,6 +1590,7 @@ cd_read_subchannel(struct cd_softc *sc, int mode, int format, int track, xs->datalen = len; xs->timeout = 5000; + cmd = (struct scsi_read_subchannel *)xs->cmd; if (mode == CD_MSF_FORMAT) cmd->byte2 |= CD_MSF; cmd->byte3 = SRS_SUBQ; @@ -1889,7 +1890,7 @@ dvd_read_physical(struct cd_softc *sc, union dvd_struct *s) u_int8_t buf[4 + 4 * 20], *bufp; int error, i; - xs = scsi_xs_get(xs->sc_link, SCSI_DATA_IN); + xs = scsi_xs_get(sc->sc_link, SCSI_DATA_IN); if (xs == NULL) return (ENOMEM); xs->cmd->opcode = GPCMD_READ_DVD_STRUCTURE; @@ -1973,21 +1974,22 @@ dvd_read_disckey(struct cd_softc *sc, union dvd_struct *s) struct scsi_xfer *xs; int error; + buf = malloc(sizeof(*buf), M_TEMP, M_WAITOK | M_ZERO); + if (buf == NULL) + return (ENOMEM); + xs = scsi_xs_get(sc->sc_link, SCSI_DATA_IN); - if (xs == NULL) + if (xs == NULL) { + free(buf, M_TEMP); return (ENOMEM); + } xs->cmd->opcode = GPCMD_READ_DVD_STRUCTURE; xs->cmdlen = sizeof(*cmd); xs->data = (void *)buf; xs->datalen = sizeof(*buf); xs->timeout = 30000; - buf = malloc(sizeof(*buf), M_TEMP, M_WAITOK | M_ZERO); - if (buf == NULL) { - scsi_xs_put(xs); - return (ENOMEM); - } - + cmd = (struct scsi_read_dvd_structure *)xs->cmd; cmd->format = s->type; cmd->agid = s->disckey.agid << 6; _lto2b(sizeof(*buf), cmd->length); @@ -2044,21 +2046,21 @@ dvd_read_manufact(struct cd_softc *sc, union dvd_struct *s) struct scsi_xfer *xs; int error; + buf = malloc(sizeof(*buf), M_TEMP, M_WAITOK | M_ZERO); + if (buf == NULL) + return (ENOMEM); + xs = scsi_xs_get(sc->sc_link, SCSI_DATA_IN); - if (xs == NULL) + if (xs == NULL) { + free(buf, M_TEMP); return (ENOMEM); + } xs->cmd->opcode = GPCMD_READ_DVD_STRUCTURE; xs->cmdlen = sizeof(*cmd); xs->data = (void *)buf; xs->datalen = sizeof(*buf); xs->timeout = 30000; - buf = malloc(sizeof(*buf), M_TEMP, M_WAITOK | M_ZERO); - if (buf == NULL) { - scsi_xs_put(xs); - return (ENOMEM); - } - cmd = (struct scsi_read_dvd_structure *)xs->cmd; cmd->format = s->type; _lto2b(sizeof(*buf), cmd->length); diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c index 0d6a1a435eb..82387004867 100644 --- a/sys/scsi/ch.c +++ b/sys/scsi/ch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ch.c,v 1.41 2010/07/22 00:31:06 krw Exp $ */ +/* $OpenBSD: ch.c,v 1.42 2010/07/22 15:59:47 matthew Exp $ */ /* $NetBSD: ch.c,v 1.26 1997/02/21 22:06:52 thorpej Exp $ */ /* @@ -385,6 +385,7 @@ ch_move(sc, cm) xs->retries = CHRETRIES; xs->timeout = 100000; + cmd = (struct scsi_move_medium *)xs->cmd; _lto2b(sc->sc_picker, cmd->tea); _lto2b(fromelem, cmd->src); _lto2b(toelem, cmd->dst); @@ -445,6 +446,7 @@ ch_exchange(sc, ce) xs->retries = CHRETRIES; xs->timeout = 100000; + cmd = (struct scsi_exchange_medium *)xs->cmd; _lto2b(sc->sc_picker, cmd->tea); _lto2b(src, cmd->src); _lto2b(dst1, cmd->fdst); @@ -494,6 +496,7 @@ ch_position(sc, cp) xs->retries = CHRETRIES; xs->timeout = 100000; + cmd = (struct scsi_position_to_element *)xs->cmd; _lto2b(sc->sc_picker, cmd->tea); _lto2b(dst, cmd->dst); if (cp->cp_flags & CP_INVERT) diff --git a/sys/scsi/safte.c b/sys/scsi/safte.c index dca4f2d9734..707573c650e 100644 --- a/sys/scsi/safte.c +++ b/sys/scsi/safte.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safte.c,v 1.43 2010/07/22 05:21:02 matthew Exp $ */ +/* $OpenBSD: safte.c,v 1.44 2010/07/22 15:59:47 matthew Exp $ */ /* * Copyright (c) 2005 David Gwynne @@ -603,6 +603,7 @@ safte_bio_blink(struct safte_softc *sc, struct bioc_blink *blink) xs->retries = 2; xs->timeout = 30000; + cmd = (struct safte_writebuf_cmd *)xs->cmd; cmd->flags |= SAFTE_WR_MODE; cmd->length = htobe16(sizeof(struct safte_slotop));