[alsa-devel] [PATCH 3/3] treewide: Remove extra ; warning

Rosen Penev rosenp at gmail.com
Tue Dec 10 10:10:47 CET 2019


Enclosed defines in a do/while loop to silence this.

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 src/conf.c            | 20 ++++++++++----------
 src/mixer/simple.c    | 16 ++++++++--------
 src/topology/parser.c |  2 +-
 src/ucm/ucm_subs.c    | 10 ++++++----
 4 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/conf.c b/src/conf.c
index e4306504..c26999b0 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -3062,7 +3062,7 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
 #ifndef DOC_HIDDEN
 
 #define SND_CONFIG_SEARCH(config, key, result, extra_code) \
-{ \
+do { \
 	snd_config_t *n; \
 	int err; \
 	const char *p; \
@@ -3081,10 +3081,10 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
 		} else \
 			return _snd_config_search(config, key, -1, result); \
 	} \
-}
+} while(0)
 
 #define SND_CONFIG_SEARCHA(root, config, key, result, fcn, extra_code) \
-{ \
+do { \
 	snd_config_t *n; \
 	int err; \
 	const char *p; \
@@ -3108,10 +3108,10 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
 		} else \
 			return _snd_config_search(config, key, -1, result); \
 	} \
-}
+} while(0)
 
 #define SND_CONFIG_SEARCHV(config, result, fcn) \
-{ \
+do { \
 	snd_config_t *n; \
 	va_list arg; \
 	assert(config); \
@@ -3132,10 +3132,10 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
 	if (result) \
 		*result = n; \
 	return 0; \
-}
+} while(0)
 
 #define SND_CONFIG_SEARCHVA(root, config, result, fcn) \
-{ \
+do { \
 	snd_config_t *n; \
 	va_list arg; \
 	assert(config); \
@@ -3156,10 +3156,10 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
 	if (result) \
 		*result = n; \
 	return 0; \
-}
+} while(0)
 
 #define SND_CONFIG_SEARCH_ALIAS(config, base, key, result, fcn1, fcn2) \
-{ \
+do { \
 	snd_config_t *res = NULL; \
 	char *old_key; \
 	int err, first = 1, maxloop = 1000; \
@@ -3201,7 +3201,7 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
 	if (result) \
 		*result = res; \
 	return 0; \
-}
+} while(0)
 
 #endif /* DOC_HIDDEN */
 
diff --git a/src/mixer/simple.c b/src/mixer/simple.c
index 2861d97c..2b9daa6e 100644
--- a/src/mixer/simple.c
+++ b/src/mixer/simple.c
@@ -82,30 +82,30 @@ int snd_mixer_selem_register(snd_mixer_t *mixer,
 #ifndef DOC_HIDDEN
 
 #define CHECK_BASIC(xelem) \
-{ \
+do { \
 	assert(xelem); \
 	assert((xelem)->type == SND_MIXER_ELEM_SIMPLE); \
-}
+} while(0)
 
 #define CHECK_DIR(xelem, xwhat) \
-{ \
+do { \
 	unsigned int xcaps = ((sm_selem_t *)(elem)->private_data)->caps; \
 	if (! (xcaps & (xwhat))) \
 		return -EINVAL; \
-}
+} while(0)
 
 #define CHECK_DIR_CHN(xelem, xwhat, xjoin, xchannel) \
-{ \
+do { \
 	unsigned int xcaps = ((sm_selem_t *)(elem)->private_data)->caps; \
 	if (! (xcaps & (xwhat))) \
 		return -EINVAL; \
 	if (xcaps & (xjoin)) \
 		xchannel = 0; \
-}
+} while(0)
 
-#define CHECK_ENUM(xelem) \
+#define CHECK_ENUM(xelem) do { \
 	if (!(((sm_selem_t *)(elem)->private_data)->caps & (SM_CAP_PENUM|SM_CAP_CENUM))) \
-		return -EINVAL;
+		return -EINVAL; } while(0)
 
 #define COND_CAPS(xelem, what) \
 	!!(((sm_selem_t *)(elem)->private_data)->caps & (what))
diff --git a/src/topology/parser.c b/src/topology/parser.c
index 5940692d..473a65e6 100644
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -382,7 +382,7 @@ int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
 	default:
 		SNDERR("error: invalid object type %d\n", t->type);
 		return -EINVAL;
-	};
+	}
 }
 
 int snd_tplg_build(snd_tplg_t *tplg, const char *outfile)
diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
index 90e395f0..5d5fd64e 100644
--- a/src/ucm/ucm_subs.c
+++ b/src/ucm/ucm_subs.c
@@ -146,15 +146,16 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char
 	return strdup(path);
 }
 
-#define MATCH_VARIABLE(name, id, fcn, empty_ok)				\
+#define MATCH_VARIABLE(name, id, fcn, empty_ok)	do {			\
 	if (strncmp((name), (id), sizeof(id) - 1) == 0) { 		\
 		rval = fcn(uc_mgr);					\
 		idsize = sizeof(id) - 1;				\
 		allow_empty = (empty_ok);				\
 		goto __rval;						\
-	}
+	}								\
+} while(0)
 
-#define MATCH_VARIABLE2(name, id, fcn)					\
+#define MATCH_VARIABLE2(name, id, fcn) do {				\
 	if (strncmp((name), (id), sizeof(id) - 1) == 0) {		\
 		idsize = sizeof(id) - 1;				\
 		tmp = strchr(value + idsize, '}');			\
@@ -170,7 +171,8 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char
 			rval = fcn(uc_mgr, v2);				\
 			goto __rval;					\
 		}							\
-	}
+	}								\
+} while(0)
 
 int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
 				 char **_rvalue,
-- 
2.23.0



More information about the Alsa-devel mailing list