Rewrite macros to not use ternary operator
authorkrj <krj@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 21 Nov 2009 10:45:35 +0000 (10:45 +0000)
committerkrj <krj@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 21 Nov 2009 10:45:35 +0000 (10:45 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31041 f5534014-38df-0310-8fa8-9805f1628bb7

epan/proto.h

index 020ac6a1df1a094acac00d030118b36d955325ce..7fab7ae7cde1ff3f4f7355aab715276cf760113d 100644 (file)
@@ -248,7 +248,11 @@ typedef struct field_info {
 /** convenience macro to get field_info.flags */
 #define FI_GET_FLAG(fi, flag) ((fi) ? (fi->flags & flag) : 0)
 /** convenience macro to set field_info.flags */
-#define FI_SET_FLAG(fi, flag) ((fi) ? (fi->flags = fi->flags | flag) : 0)
+#define FI_SET_FLAG(fi, flag) \
+    G_STMT_START \
+    if (fi) \
+      (fi)->flags = (fi)->flags | (flag); \
+    G_STMT_END
 
 /** One of these exists for the entire protocol tree. Each proto_node
  * in the protocol tree points to the same copy. */
@@ -323,19 +327,28 @@ typedef proto_node proto_item;
 /** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
 #define PROTO_ITEM_SET_HIDDEN(proto_item)       \
-       ((proto_item = proto_item) ? FI_SET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN) : 0)
+  G_STMT_START \
+       if (proto_item) \
+    FI_SET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
+       G_STMT_END
 /** is this protocol field generated by Wireshark (and not read from the packet data)? */
 #define PROTO_ITEM_IS_GENERATED(proto_item)    \
        ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED) : 0)
 /** mark this protocol field as generated by Wireshark (and not read from the packet data) */
 #define PROTO_ITEM_SET_GENERATED(proto_item)   \
-       ((proto_item = proto_item) ? FI_SET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED) : 0)
+    G_STMT_START \
+    if (proto_item) \
+      FI_SET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED); \
+    G_STMT_END
 /** is this protocol field actually a URL? */
 #define PROTO_ITEM_IS_URL(proto_item)  \
        ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_URL) : 0)
 /** mark this protocol field as a URL */
 #define PROTO_ITEM_SET_URL(proto_item) \
-       ((proto_item) ? FI_SET_FLAG(PITEM_FINFO(proto_item), FI_URL) : 0)
+    G_STMT_START \
+    if (proto_item) \
+      FI_SET_FLAG(PITEM_FINFO(proto_item), FI_URL); \
+    G_STMT_END
 
 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
 typedef gboolean (*proto_tree_traverse_func)(proto_node *, gpointer);