diff options
| author | christos <christos@NetBSD.org> | 2006-04-14 22:52:00 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2006-04-14 22:52:00 +0000 |
| commit | 407368a46ebd03a2d5668edb6bfaeecb18d4c2ae (patch) | |
| tree | 860e1ae45ea6263591b2a01f0d5163c3733bdff4 /sys/dev/isa | |
| parent | 24f5b2aec3aa99303d891b83d7c8bfeda94f004a (diff) | |
Coverity CID 2453: Add negative checks.
Diffstat (limited to 'sys/dev/isa')
| -rw-r--r-- | sys/dev/isa/gus.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index 1f78e5b64e6..9162dab7baa 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $NetBSD: gus.c,v 1.92 2006/03/25 23:14:58 thorpej Exp $ */ +/* $NetBSD: gus.c,v 1.93 2006/04/14 22:52:00 christos Exp $ */ /*- * Copyright (c) 1996, 1999 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.92 2006/03/25 23:14:58 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.93 2006/04/14 22:52:00 christos Exp $"); #include "gus.h" #if NGUS > 0 @@ -825,7 +825,8 @@ gusattach(struct device *parent, struct device *self, void *aux) bus_space_tag_t iot; bus_space_handle_t ioh1, ioh2, ioh3, ioh4; int iobase, i; - unsigned char c,d,m; + unsigned char c, m; + int d = -1; const struct audio_hw_if *hwif; sc = (void *) self; @@ -892,12 +893,17 @@ gusattach(struct device *parent, struct device *self, void *aux) c = ((unsigned char) gus_irq_map[ia->ia_irq[0].ir_irq]) | GUSMASK_BOTH_RQ; - if (sc->sc_recdrq == sc->sc_playdrq) - d = (unsigned char) (gus_drq_map[sc->sc_playdrq] | - GUSMASK_BOTH_RQ); - else - d = (unsigned char) (gus_drq_map[sc->sc_playdrq] | - gus_drq_map[sc->sc_recdrq] << 3); + if (sc->sc_playdrq != -1) { + if (sc->sc_recdrq == sc->sc_playdrq) + d = (unsigned char) (gus_drq_map[sc->sc_playdrq] | + GUSMASK_BOTH_RQ); + else if (sc->sc_recdrq != -1) + d = (unsigned char) (gus_drq_map[sc->sc_playdrq] | + gus_drq_map[sc->sc_recdrq] << 3); + } + if (d == -1) + printf("%s: WARNING: Cannot initialize drq\n", + sc->sc_dev.dv_xname); /* * Program the IRQ and DMA channels on the GUS. Note that we hardwire |
