diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-03-14 18:53:14 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-03-14 18:53:14 +0000 |
commit | 1033b63777491693c4a054ff49f9c83284255454 (patch) | |
tree | a619da0bd1fc86364055e355ccd5bc76d1e7feac /sys/dev/ic | |
parent | 4fd337c69ab35acd05840e6d18a2ccd4869eae5b (diff) |
ahci_get_pmp_ccb() returns a non-NULL pointer, fails a
KASSERT(), or has already blown up by dereferencing the
pointer.
Two of the four invocations of ahci_get_pmp_ccb() check for
NULL. Save a couple of bytes by not bothering. Add comments
to the invocations to docuement the assumption.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/ahci.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index bb3ebbf6047..679a8ff0f88 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ahci.c,v 1.35 2020/03/14 16:46:51 krw Exp $ */ +/* $OpenBSD: ahci.c,v 1.36 2020/03/14 18:53:13 krw Exp $ */ /* * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> @@ -1131,7 +1131,7 @@ ahci_pmp_port_softreset(struct ahci_port *ap, int pmp_port) ahci_pmp_write(ap, pmp_port, SATA_PMREG_SERR, -1); /* send first softreset FIS */ - ccb = ahci_get_pmp_ccb(ap); + ccb = ahci_get_pmp_ccb(ap); /* Always returns non-NULL. */ cmd_slot = ccb->ccb_cmd_hdr; memset(ccb->ccb_cmd_table, 0, sizeof(struct ahci_cmd_table)); @@ -1151,7 +1151,7 @@ ahci_pmp_port_softreset(struct ahci_port *ap, int pmp_port) PORTNAME(ap), pmp_port); if (ahci_poll(ccb, 1000, ahci_pmp_probe_timeout) != 0) { printf("%s.%d: PMP port softreset cmd failed\n", - PORTNAME(ap), pmp_port); + PORTNAME(ap), pmp_port); rc = EBUSY; if (count > 0) { /* probably delay a while to allow @@ -1618,7 +1618,7 @@ ahci_port_detect_pmp(struct ahci_port *ap) /* Prep first command with SRST feature & * clear busy/reset flags */ - ccb = ahci_get_pmp_ccb(ap); + ccb = ahci_get_pmp_ccb(ap); /* Always returns non-NULL. */ cmd_slot = ccb->ccb_cmd_hdr; memset(ccb->ccb_cmd_table, 0, sizeof(struct ahci_cmd_table)); @@ -3005,11 +3005,7 @@ ahci_pmp_read(struct ahci_port *ap, int target, int which, u_int32_t *datap) struct ata_fis_h2d *fis; int error; - ccb = ahci_get_pmp_ccb(ap); - if (ccb == NULL) { - printf("%s: NULL ccb!\n", PORTNAME(ap)); - return (1); - } + ccb = ahci_get_pmp_ccb(ap); /* Always returns non-NULL. */ ccb->ccb_xa.flags = ATA_F_POLL | ATA_F_GET_RFIS; ccb->ccb_xa.pmp_port = SATA_PMP_CONTROL_PORT; ccb->ccb_xa.state = ATA_S_PENDING; @@ -3043,11 +3039,7 @@ ahci_pmp_write(struct ahci_port *ap, int target, int which, u_int32_t data) struct ata_fis_h2d *fis; int error; - ccb = ahci_get_pmp_ccb(ap); - if (ccb == NULL) { - printf("%s: NULL ccb!\n", PORTNAME(ap)); - return (1); - } + ccb = ahci_get_pmp_ccb(ap); /* Always returns non-NULL. */ ccb->ccb_xa.flags = ATA_F_POLL; ccb->ccb_xa.pmp_port = SATA_PMP_CONTROL_PORT; ccb->ccb_xa.state = ATA_S_PENDING; |