[Sound-open-firmware] [PATCH 06/10] volume: replace switch by if for readability

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Mon Sep 25 21:52:14 CEST 2017


MISRA C:2012, 16.5: Every switch statement shall have at least two
switch-clauses

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
---
 src/audio/volume.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/audio/volume.c b/src/audio/volume.c
index 96d1974..68c8453 100644
--- a/src/audio/volume.c
+++ b/src/audio/volume.c
@@ -476,18 +476,14 @@ static int volume_ctrl_get_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *c
 		return -EINVAL;
 	}
 
-	switch (cdata->cmd) {
-	case SOF_CTRL_CMD_VOLUME:
-
+	if (cdata->cmd == SOF_CTRL_CMD_VOLUME) {
 		for (i = 0; i < cdata->num_elems; i++) {
 			for (j = 0; j < cdata->num_elems; j++) {
 				if (cdata->chanv[j].value == cd->chan[i])
 					cdata->chanv[j].value = cd->tvolume[i];
 			}
 		}
-
-		break;
-	default:
+	} else {
 		trace_volume_error("ec2");
 		return -EINVAL;
 	}
-- 
2.11.0



More information about the Sound-open-firmware mailing list