mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
sound: Remove unncessary locking in sysctl_hw_snd_hwvol_mixer()
The locking around strlcpy() was because of m->hwvol_mixer, but this is just an int, so we don't need to lock in this case. Instead lock only when m->hwvol_mixer is written. While here, add parentheses around the returns. Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D59109
This commit is contained in:
1 parent
db62d784f0
commit
044ef293a8
1 file changed
+6
-12
@@ -698,22 +698,16 @@ sysctl_hw_snd_hwvol_mixer(SYSCTL_HANDLER_ARGS)
|
||||
struct snd_mixer *m;
|
||||
|
||||
m = oidp->oid_arg1;
|
||||
mtx_lock(m->lock);
|
||||
strlcpy(devname, snd_mixernames[m->hwvol_mixer], sizeof(devname));
|
||||
mtx_unlock(m->lock);
|
||||
error = sysctl_handle_string(oidp, &devname[0], sizeof(devname), req);
|
||||
mtx_lock(m->lock);
|
||||
if (error == 0 && req->newptr != NULL) {
|
||||
dev = mixer_lookup(devname);
|
||||
if (dev == -1) {
|
||||
mtx_unlock(m->lock);
|
||||
return EINVAL;
|
||||
} else {
|
||||
m->hwvol_mixer = dev;
|
||||
}
|
||||
if ((dev = mixer_lookup(devname)) == -1)
|
||||
return (EINVAL);
|
||||
mtx_lock(m->lock);
|
||||
m->hwvol_mixer = dev;
|
||||
mtx_unlock(m->lock);
|
||||
}
|
||||
mtx_unlock(m->lock);
|
||||
return error;
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in new issue
Block a user