[alsa-devel] [PATCH RFC 07/21] ALSA: pcm: remove function local variable with alternative evaluation

Takashi Sakamoto o-takashi at sakamocchi.jp
Sun May 14 10:57:42 CEST 2017


A local variable is used to judge whether a parameter should be handled
due to reverse dependency of the other rules. However, this can be
obsoleted by check of a sentinel in dependency array.

This commit removes the local variable and check the sentinel to reduce
stack usage.

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 sound/core/pcm_native.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 4de9498..39ead67 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -351,16 +351,13 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream,
 	for (k = 0; k < constrs->rules_num; k++) {
 		struct snd_pcm_hw_rule *r = &constrs->rules[k];
 		unsigned int d;
-		int doit = 0;
 		if (r->cond && !(r->cond & params->flags))
 			continue;
 		for (d = 0; r->deps[d] >= 0; d++) {
-			if (vstamps[r->deps[d]] > rstamps[k]) {
-				doit = 1;
+			if (vstamps[r->deps[d]] > rstamps[k])
 				break;
-			}
 		}
-		if (!doit)
+		if (r->deps[d] < 0)
 			continue;
 
 		/* Keep old parameter to trace. */
-- 
2.9.3



More information about the Alsa-devel mailing list