commit a247c24486bdb938591e98224dd92567dff93ef9
parent 0e489e949e8639bebfe30c41f33f423107a78ccf
Author: Christos Margiolis <christos@margiolis.net>
Date: Thu, 26 Aug 2021 17:07:36 +0300
mixer(3): fixed post assignment check in mixer_remove_ctl()
Diffstat:
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/lol b/lol
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd mixer_lib && doas make all install clean cleandepend && cd ..
+cd mixer_prog && doas make all install clean cleandepend && cd ..
diff --git a/mixer_lib/mixer.c b/mixer_lib/mixer.c
@@ -261,12 +261,13 @@ mixer_add_ctl_s(mix_ctl_t *ctl)
int
mixer_remove_ctl(mix_ctl_t *ctl)
{
- struct mix_dev *p = ctl->parent_dev;
+ struct mix_dev *p;
if (ctl == NULL) {
errno = EINVAL;
return (-1);
}
+ p = ctl->parent_dev;
if (!TAILQ_EMPTY(&p->ctls)) {
TAILQ_REMOVE(&p->ctls, ctl, ctls);
free(ctl);
diff --git a/mixer_prog/mixer_prog.c b/mixer_prog/mixer_prog.c
@@ -184,14 +184,19 @@ static void
initctls(struct mixer *m)
{
struct mix_dev *dp;
+ int rc = 0;
#define C_VOL 0
#define C_MUT 1
#define C_SRC 2
TAILQ_FOREACH(dp, &m->devs, devs) {
- (void)mixer_add_ctl(dp, C_VOL, "volume", mod_volume, print_volume);
- (void)mixer_add_ctl(dp, C_MUT, "mute", mod_mute, print_mute);
- (void)mixer_add_ctl(dp, C_SRC, "recsrc", mod_recsrc, print_recsrc);
+ rc += mixer_add_ctl(dp, C_VOL, "volume", mod_volume, print_volume);
+ rc += mixer_add_ctl(dp, C_MUT, "mute", mod_mute, print_mute);
+ rc += mixer_add_ctl(dp, C_SRC, "recsrc", mod_recsrc, print_recsrc);
+ }
+ if (rc) {
+ (void)mixer_close(m);
+ err(1, "cannot make controls");
}
}