[icinga-checkins] icinga.org: icinga-core/rbartels/1.3: force my_free() macro users to end the statement with a semi-colon (Andreas Ericsson) #927

git at icinga.org git at icinga.org
Thu Nov 11 19:54:25 CET 2010


Module: icinga-core
Branch: rbartels/1.3
Commit: 40cf0b33ac57e3a5f2f3a015508d0e711e56158e
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=40cf0b33ac57e3a5f2f3a015508d0e711e56158e

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Mon Oct 25 13:31:41 2010 +0200

force my_free() macro users to end the statement with a semi-colon (Andreas Ericsson) #927

The old void-function replacement macro idiom

  do { things(); } while (0)

has the loop there for a reason. This makes it easy to convert back
to a function later since we'll know that the semi-colon is there
if the code compiles.

Signed-off-by: Andreas Ericsson <ae at op5.se>

Author: Andreas Ericsson <ae at op5.se>

refs #927

---

 Changelog        |    1 +
 include/common.h |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Changelog b/Changelog
index bbccadf..044ce19 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ ENHANCEMENTS
 FIXES
 * core: base/utils: Refactor my_fcopy() (Andreas Ericsson) #427
 * core: base/nebmods: Replace local file-copy hack with my_fdcopy() (Andreas Ericsson) #424
+* core: force my_free() macro users to end the statement with a semi-colon (Andreas Ericsson) #927
 
 
 1.2.1 - 25/10/2010
diff --git a/include/common.h b/include/common.h
index ed15ae6..1cf147f 100644
--- a/include/common.h
+++ b/include/common.h
@@ -48,7 +48,7 @@
 #undef USE_MEMORY_PERFORMANCE_TWEAKS
 
 /* my_free has been freed from bondage as a function */
-#define my_free(ptr) { if(ptr) { free(ptr); ptr = NULL; } }
+#define my_free(ptr) do { if(ptr) { free(ptr); ptr = NULL; } } while(0)
 
 
 





More information about the icinga-checkins mailing list