mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
Replace some assert() with runtime checks
assert() for sanity checks that can happen in runtime isn't a good idea. Replaced it with the real check. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
16cc295a3c
commit
5cee69b47b
1 changed files with 9 additions and 2 deletions
|
|
@ -324,7 +324,11 @@ static int snd_ctl_hw_read(snd_ctl_t *handle, snd_ctl_event_t *event)
|
||||||
ssize_t res = read(hw->fd, event, sizeof(*event));
|
ssize_t res = read(hw->fd, event, sizeof(*event));
|
||||||
if (res <= 0)
|
if (res <= 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
assert(res == sizeof(*event));
|
if (CHECK_SANITY(res != sizeof(*event))) {
|
||||||
|
SNDMSG("snd_ctl_hw_read: read size error (req:%d, got:%d)\n",
|
||||||
|
sizeof(*event), res);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,7 +372,10 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
|
||||||
|
|
||||||
*handle = NULL;
|
*handle = NULL;
|
||||||
|
|
||||||
assert(card >= 0 && card < 32);
|
if (CHECK_SANITY(card < 0 || card >= 32)) {
|
||||||
|
SNDMSG("Invalid card index %d", card);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
sprintf(filename, SNDRV_FILE_CONTROL, card);
|
sprintf(filename, SNDRV_FILE_CONTROL, card);
|
||||||
if (mode & SND_CTL_READONLY)
|
if (mode & SND_CTL_READONLY)
|
||||||
fmode = O_RDONLY;
|
fmode = O_RDONLY;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue