[Devel] Make "if (...) SOME_MACRO(); else" compile

Igor Podlesny openvz at poige.ru
Sun Apr 28 20:31:44 PDT 2013


Otherwise it would expand to:
"if (...) do { ... } while(0); ; else" which obviously is syntax error.
---
 include/image.h  |    2 +-
 src/vzcfgscale.c |   18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/image.h b/include/image.h
index 2dc679c..98563e3 100644
--- a/include/image.h
+++ b/include/image.h
@@ -71,7 +71,7 @@ do {								\
 	__cl_h = add_cleanup_handler(cancel_ploop_op, NULL);	\
 	code;							\
 	del_cleanup_handler(__cl_h);				\
-} while(0);
+} while(0)
 
 int is_image_mounted(const char *ve_private);
 int vzctl_create_image(const char *ve_private, struct vzctl_create_image_param *param);
diff --git a/src/vzcfgscale.c b/src/vzcfgscale.c
index 420dda5..3376d70 100644
--- a/src/vzcfgscale.c
+++ b/src/vzcfgscale.c
@@ -56,16 +56,16 @@ do { \
 		free(param->name); \
 		param->name = NULL; \
 	} \
-} while (0); \
+} while (0) \
 
-	FREE_PARAM(hostname)
-	FREE_PARAM(nameserver)
-	FREE_PARAM(searchdomain)
-	FREE_PARAM(tmpl_set)
-	FREE_PARAM(ve_root_orig)
-	FREE_PARAM(ve_private_orig)
-	FREE_PARAM(shared_base_id)
-	FREE_PARAM(templates)
+	FREE_PARAM(hostname);
+	FREE_PARAM(nameserver);
+	FREE_PARAM(searchdomain);
+	FREE_PARAM(tmpl_set);
+	FREE_PARAM(ve_root_orig);
+	FREE_PARAM(ve_private_orig);
+	FREE_PARAM(shared_base_id);
+	FREE_PARAM(templates);
 	ListFree(param->ipadd);
 	param->ipadd =  NULL;
 }
-- 
1.7.9.5




More information about the Devel mailing list