Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1565771
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 6/7] dmasound_core: Move two assignments for the variable "ret" in state_open() |
| Date | 2017-01-24 11:30 +0100 |
| Message-ID | <t36wr-34u-43@gated-at.bofh.it> (permalink) |
| References | <t36wq-34u-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Jan 2017 10:05:29 +0100
A local variable was set to an error code in two cases before a concrete
error situation was detected. Thus move the corresponding assignments into
if branches to indicate a software failure there.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/oss/dmasound/dmasound_core.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index f4ee85a4c42f..2bdd1d619a7f 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -1269,13 +1269,15 @@ static int state_open(struct inode *inode, struct file *file)
int ret;
mutex_lock(&dmasound_core_mutex);
- ret = -EBUSY;
- if (state.busy)
+ if (state.busy) {
+ ret = -EBUSY;
goto out;
+ }
- ret = -ENODEV;
- if (!try_module_get(dmasound.mach.owner))
+ if (!try_module_get(dmasound.mach.owner)) {
+ ret = -ENODEV;
goto out;
+ }
state.ptr = 0;
state.busy = 1;
--
2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/7] ALSA: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
[PATCH 7/7] dmasound_core: Adjust six function calls together with a variable assignment SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
[PATCH 2/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_get_subscription() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
[PATCH 1/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_query_subs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
[PATCH 6/7] dmasound_core: Move two assignments for the variable "ret" in state_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
Re: [alsa-devel] [PATCH 6/7] dmasound_core: Move two assignments for the variable "ret" in state_open() Clemens Ladisch <clemens@ladisch.de> - 2017-01-25 08:50 +0100
[PATCH 5/7] ALSA: seq: Adjust 16 function calls together with a variable assignment SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
[PATCH 4/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_subscribe_port() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
csiph-web