Convert NULL checks into KASSERT (and move them before the first
dereferencing) since a NULL value would be a bug here. Note: Both affected functions look very similar. A refactoring may be beneficial. CID: 483, 485 Found with: Coverity Prevent(tm) Discussed with: ariff MFC after: 5 days
This commit is contained in:
parent
98ba0aaf4b
commit
363262abcc
@ -862,6 +862,10 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
|
||||
|
||||
SLIST_FOREACH(sce, &d->channels, link) {
|
||||
c = sce->channel;
|
||||
|
||||
KASSERT(c->bufhard != NULL && c->bufsoft != NULL,
|
||||
("hosed pcm channel setup"));
|
||||
|
||||
sbuf_printf(s, "\n\t");
|
||||
|
||||
/* it would be better to indent child channels */
|
||||
@ -877,24 +881,22 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
|
||||
sbuf_printf(s, ", pid %d", c->pid);
|
||||
sbuf_printf(s, "\n\t");
|
||||
|
||||
if (c->bufhard != NULL && c->bufsoft != NULL) {
|
||||
sbuf_printf(s, "interrupts %d, ", c->interrupts);
|
||||
if (c->direction == PCMDIR_REC)
|
||||
sbuf_printf(s, "overruns %d, hfree %d, sfree %d [b:%d/%d/%d|bs:%d/%d/%d]",
|
||||
c->xruns, sndbuf_getfree(c->bufhard), sndbuf_getfree(c->bufsoft),
|
||||
sndbuf_getsize(c->bufhard), sndbuf_getblksz(c->bufhard),
|
||||
sndbuf_getblkcnt(c->bufhard),
|
||||
sndbuf_getsize(c->bufsoft), sndbuf_getblksz(c->bufsoft),
|
||||
sndbuf_getblkcnt(c->bufsoft));
|
||||
else
|
||||
sbuf_printf(s, "underruns %d, ready %d [b:%d/%d/%d|bs:%d/%d/%d]",
|
||||
c->xruns, sndbuf_getready(c->bufsoft),
|
||||
sndbuf_getsize(c->bufhard), sndbuf_getblksz(c->bufhard),
|
||||
sndbuf_getblkcnt(c->bufhard),
|
||||
sndbuf_getsize(c->bufsoft), sndbuf_getblksz(c->bufsoft),
|
||||
sndbuf_getblkcnt(c->bufsoft));
|
||||
sbuf_printf(s, "\n\t");
|
||||
}
|
||||
sbuf_printf(s, "interrupts %d, ", c->interrupts);
|
||||
if (c->direction == PCMDIR_REC)
|
||||
sbuf_printf(s, "overruns %d, hfree %d, sfree %d [b:%d/%d/%d|bs:%d/%d/%d]",
|
||||
c->xruns, sndbuf_getfree(c->bufhard), sndbuf_getfree(c->bufsoft),
|
||||
sndbuf_getsize(c->bufhard), sndbuf_getblksz(c->bufhard),
|
||||
sndbuf_getblkcnt(c->bufhard),
|
||||
sndbuf_getsize(c->bufsoft), sndbuf_getblksz(c->bufsoft),
|
||||
sndbuf_getblkcnt(c->bufsoft));
|
||||
else
|
||||
sbuf_printf(s, "underruns %d, ready %d [b:%d/%d/%d|bs:%d/%d/%d]",
|
||||
c->xruns, sndbuf_getready(c->bufsoft),
|
||||
sndbuf_getsize(c->bufhard), sndbuf_getblksz(c->bufhard),
|
||||
sndbuf_getblkcnt(c->bufhard),
|
||||
sndbuf_getsize(c->bufsoft), sndbuf_getblksz(c->bufsoft),
|
||||
sndbuf_getblkcnt(c->bufsoft));
|
||||
sbuf_printf(s, "\n\t");
|
||||
|
||||
sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC)? "hardware" : "userland");
|
||||
sbuf_printf(s, " -> ");
|
||||
|
@ -4465,6 +4465,9 @@ uaudio_sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
|
||||
c = sce->channel;
|
||||
sbuf_printf(s, "\n\t");
|
||||
|
||||
KASSERT(c->bufhard != NULL && c->bufsoft != NULL,
|
||||
("hosed pcm channel setup"));
|
||||
|
||||
/* it would be better to indent child channels */
|
||||
sbuf_printf(s, "%s[%s]: ", c->parentchannel? c->parentchannel->name : "", c->name);
|
||||
sbuf_printf(s, "spd %d", c->speed);
|
||||
@ -4478,16 +4481,14 @@ uaudio_sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
|
||||
sbuf_printf(s, ", pid %d", c->pid);
|
||||
sbuf_printf(s, "\n\t");
|
||||
|
||||
if (c->bufhard != NULL && c->bufsoft != NULL) {
|
||||
sbuf_printf(s, "interrupts %d, ", c->interrupts);
|
||||
if (c->direction == PCMDIR_REC)
|
||||
sbuf_printf(s, "overruns %d, hfree %d, sfree %d",
|
||||
c->xruns, sndbuf_getfree(c->bufhard), sndbuf_getfree(c->bufsoft));
|
||||
else
|
||||
sbuf_printf(s, "underruns %d, ready %d",
|
||||
c->xruns, sndbuf_getready(c->bufsoft));
|
||||
sbuf_printf(s, "\n\t");
|
||||
}
|
||||
sbuf_printf(s, "interrupts %d, ", c->interrupts);
|
||||
if (c->direction == PCMDIR_REC)
|
||||
sbuf_printf(s, "overruns %d, hfree %d, sfree %d",
|
||||
c->xruns, sndbuf_getfree(c->bufhard), sndbuf_getfree(c->bufsoft));
|
||||
else
|
||||
sbuf_printf(s, "underruns %d, ready %d",
|
||||
c->xruns, sndbuf_getready(c->bufsoft));
|
||||
sbuf_printf(s, "\n\t");
|
||||
|
||||
sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC)? "hardware" : "userland");
|
||||
sbuf_printf(s, " -> ");
|
||||
|
Loading…
Reference in New Issue
Block a user