[Devel] [PATCH 4/7] SCALE_PARAM, SCALE_UBC gets shorter

Igor Podlesny openvz at poige.ru
Mon May 13 01:39:20 PDT 2013


Both macroses started with framing if() so we don't have
to bring in artificial do {} while (0) "loop"
---
 src/vzcfgscale.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/vzcfgscale.c b/src/vzcfgscale.c
index 99f871d..414aec5 100644
--- a/src/vzcfgscale.c
+++ b/src/vzcfgscale.c
@@ -76,9 +76,7 @@ void scale(float ubc_k, float cpu_k, float disk_k, float net_k,
 	unsigned long val0, val1;
 
 #define SCALE_UBC(name, k) \
-do { \
-	if (param->name == NULL) \
-		break; \
+if (param->name != NULL) { \
 	val0 = param->name[0]; \
 	val1 = param->name[1]; \
 	if (val0 != LONG_MAX) \
@@ -91,19 +89,17 @@ do { \
 		val1 = LONG_MAX; \
 	param->name[0] = val0; \
 	param->name[1] = val1; \
-} while(0)
+} else
 
 #define SCALE_PARAM(name, k) \
-do { \
-	if (param->name == NULL) \
-		break; \
+if (param->name != NULL) { \
 	param->name[0] *= k; \
 	param->name[1] *= k; \
 	if (param->name[0] > LONG_MAX) \
 		param->name[0] = LONG_MAX; \
 	if (param->name[1] > LONG_MAX) \
 		param->name[1] = LONG_MAX; \
-} while(0)
+} else
 
 	if (ubc_k)
 	{
-- 
1.7.9.5




More information about the Devel mailing list