[gnumeric] Style: make macros statement-safe.



commit 6b8e3861468821dbf0ef26fd3ac81bf90cec6714
Author: Morten Welinder <terra gnome org>
Date:   Thu Mar 8 20:48:36 2012 -0500

    Style: make macros statement-safe.

 src/gnm-style-impl.h |    8 ++++----
 src/mstyle.c         |    4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/gnm-style-impl.h b/src/gnm-style-impl.h
index 5b3a815..2cbdcb1 100644
--- a/src/gnm-style-impl.h
+++ b/src/gnm-style-impl.h
@@ -66,10 +66,10 @@ struct _GnmStyle {
 	GPtrArray		*cond_styles;
 };
 
-#define elem_changed(style, elem) { (style)->changed |= (1 << (elem)); }
-#define elem_set(style, elem)	  { (style)->set |=  (1 << (elem)); }
-#define elem_unset(style, elem)	  { (style)->set &= ~(1 << (elem)); }
-#define elem_is_set(style, elem)  (((style)->set & (1 << (elem))) != 0)
+#define elem_changed(style, elem) do { (style)->changed |= (1u << (elem)); } while(0)
+#define elem_set(style, elem)	  do { (style)->set |=  (1u << (elem)); } while(0)
+#define elem_unset(style, elem)	  do { (style)->set &= ~(1u << (elem)); } while(0)
+#define elem_is_set(style, elem)  (((style)->set & (1u << (elem))) != 0)
 
 #define MSTYLE_ANY_BORDER            MSTYLE_BORDER_TOP: \
 				case MSTYLE_BORDER_BOTTOM: \
diff --git a/src/mstyle.c b/src/mstyle.c
index 16085ca..ca8e27f 100644
--- a/src/mstyle.c
+++ b/src/mstyle.c
@@ -461,14 +461,14 @@ gnm_style_find_conflicts (GnmStyle *accum, GnmStyle const *overlay,
 	g_assert (MSTYLE_ELEMENT_MAX <= CHAR_BIT * sizeof (conflicts));
 
 	for (i = 0; i < MSTYLE_ELEMENT_MAX; i++) {
-		if (conflicts & (1 << i) || !elem_is_set (overlay, i)) {
+		if (conflicts & (1u << i) || !elem_is_set (overlay, i)) {
 			/* Nothing */
 		} else if (!elem_is_set (accum, i)) {
 			elem_assign_contents (accum, overlay, i);
 			elem_set (accum, i);
 			elem_changed (accum, i);
 		} else if (!elem_is_eq (accum, overlay, i))
-			conflicts |= (1 << i);
+			conflicts |= (1u << i);
 	}
 
 	return conflicts;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]