Use val_to_str() instead of blindly passing the return value from match_strval()
authormorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 17 May 2011 18:53:35 +0000 (18:53 +0000)
committermorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 17 May 2011 18:53:35 +0000 (18:53 +0000)
into a format routine (to ensure a non-NULL string pointer).

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@37203 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-dvbci.c
epan/dissectors/packet-reload.c
epan/dissectors/packet-stun.c
epan/dissectors/packet-xcsl.c

index 86fd7b8e41b0a922740e8773b275fa3cf6fddd11..95650c307a5c77af6c713871a60b7ffecc6c4367 100644 (file)
@@ -598,7 +598,7 @@ dissect_dvbci_payload_rm(guint32 tag, gint len_field,
 
    if (tag==T_PROFILE) {
        if (len_field % RES_ID_LEN) {
-           tag_str = match_strval(tag, dvbci_apdu_tag);
+           tag_str = val_to_str(tag, dvbci_apdu_tag, "Unknown: %d");
            pi = proto_tree_add_text(tree, tvb, 0, APDU_TAG_SIZE,
                    "Invalid APDU length field");
            expert_add_info_format(pinfo, pi, PI_MALFORMED, PI_ERROR,
@@ -669,7 +669,7 @@ dissect_dvbci_payload_ca(guint32 tag, gint len_field,
 
     if (tag==T_CA_INFO) {
         if (len_field % 2) {
-            tag_str = match_strval(tag, dvbci_apdu_tag);
+            tag_str = val_to_str(tag, dvbci_apdu_tag, "Unknown: %d");
             pi = proto_tree_add_text(tree, tvb, 0, APDU_TAG_SIZE,
                     "Invalid APDU length field");
             expert_add_info_format(pinfo, pi, PI_MALFORMED, PI_ERROR,
index fc8901c9e1cc43ef4b1479a18410f32ce830b6c1..1460ccd2437ef81ae3cae930f8ab3e0892bb90ea 100644 (file)
@@ -1297,11 +1297,8 @@ dissect_reload_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     proto_item_append_text(ti, ": %s %s", msg_class_str, val_to_str(error_code, errorcodes, "Unknown"));
   }
   else {
-    msg_class_str = match_strval(MSGCODE_TO_CLASS(message_code), classes);
-    msg_method_str = match_strval(MSGCODE_TO_METHOD(message_code), methods);
-
-    if (msg_method_str == NULL)
-      msg_method_str = "Unknown";
+    msg_class_str = val_to_str(MSGCODE_TO_CLASS(message_code), classes, "Unknown %d");
+    msg_method_str = val_to_str(MSGCODE_TO_METHOD(message_code), methods, "Unknown %d");
 
     col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
                  msg_method_str, msg_class_str);
index 20f7f63d260d65c32ecd046b9ee74410c060eaf4..6280793be4c0abb910ba2238d84f2c5abb5cb40d 100644 (file)
@@ -543,11 +543,8 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        }
 
 
-       msg_class_str = match_strval(msg_type_class, classes);
-       msg_method_str = match_strval(msg_type_method, methods);
-
-       if (msg_method_str == NULL)
-               msg_method_str = "Unknown";
+       msg_class_str = val_to_str_const(msg_type_class, classes, "Unknown");
+       msg_method_str = val_to_str_const(msg_type_method, methods, "Unknown");
 
        if(check_col(pinfo->cinfo,COL_INFO)) {
                col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
@@ -641,13 +638,13 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        proto_tree_add_uint(att_type_tree, stun_att_type_comprehension, tvb, offset, 2, att_type);
                        ti = proto_tree_add_text(att_type_tree, tvb, offset, 2,
                                                 "%s (%d)",
-                                                match_strval((att_type & 0x8000) >> 15, comprehensions),
+                                                val_to_str((att_type & 0x8000) >> 15, comprehensions, "Unknown: %d"),
                                                 (att_type & 0x8000) >> 15);
                        PROTO_ITEM_SET_GENERATED(ti);
                        proto_tree_add_uint(att_type_tree, stun_att_type_assignment, tvb, offset, 2, att_type);
                        ti = proto_tree_add_text(att_type_tree, tvb, offset, 2,
                                                 "%s (%d)",
-                                                match_strval((att_type & 0x4000) >> 14, assignments),
+                                                val_to_str((att_type & 0x4000) >> 14, assignments, "Unknown: %d"),
                                                 (att_type & 0x4000) >> 14);
                        PROTO_ITEM_SET_GENERATED(ti);
 
index 9382bb0ed51ffcf700c2077152f534e2feb9c08c..04bc55258a764aa00f82e6fa1afa99829ee28274 100644 (file)
@@ -67,7 +67,7 @@ static gint ett_xcsl = -1;
 #define XCSL_PROTSEQERR   8
 #define XCSL_NONE         9
 
-/* Result code meanings. See function match_strval() for usage */
+/* Result code meanings. */
 static const value_string xcsl_action_vals[] = {
    { XCSL_SUCCESS,    "Success" },
    { XCSL_UNKNOWN,    "Unknown" },
@@ -218,7 +218,7 @@ static void dissect_xcsl_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
                       if ( result >= XCSL_NONE ) {
                          result = XCSL_UNDEFINED;
                       }
-                      code = match_strval(result, xcsl_action_vals);
+                      code = val_to_str(result, xcsl_action_vals, "Unknown: %d");
 
                       /* Print result code and description */
                       xcsl_item = proto_tree_add_item(tree, hf_xcsl_result, tvb, offset, len, FALSE);