Fix various Visual C++ analysis warnings.
authorGerald Combs <gerald@wireshark.org>
Thu, 17 Feb 2011 19:43:16 +0000 (19:43 -0000)
committerGerald Combs <gerald@wireshark.org>
Thu, 17 Feb 2011 19:43:16 +0000 (19:43 -0000)
svn path=/trunk/; revision=35985

epan/dissectors/packet-3g-a11.c
epan/dissectors/packet-afs.c
epan/dissectors/packet-aim.c
epan/dissectors/packet-alcap.c
epan/dissectors/packet-amr.c
epan/dissectors/packet-ansi_a.c
epan/dissectors/packet-aoe.c

index d3c169d1b1c5f0a2ddabcad0ccb2d6f02a9b99b0..fc4b216fee0417eac3cbd56c782053d26f7dd377 100644 (file)
@@ -1375,7 +1375,7 @@ dissect_a11( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
     /* Set up structures we will need to add the protocol subtree and manage it */
     proto_item   *ti;
-    proto_tree   *a11_tree;
+    proto_tree   *a11_tree = NULL;
     proto_item   *tf;
     proto_tree   *flags_tree;
     guint8        type;
@@ -1673,7 +1673,7 @@ dissect_a11( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         break;
     } /* End switch */
 
-    if (tree) {
+    if (tree && a11_tree) {
         if (tvb_reported_length_remaining(tvb, offset) > 0)
             dissect_a11_extensions(tvb, offset, a11_tree);
     }
index 32e6ae57ae2ebf4267aeb64ef43aa4dcb755948f..61aee1bce658c1add31887ea7397e7c7977c3031 100644 (file)
@@ -1702,7 +1702,7 @@ dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offs
        int old_offset;
        gint32 bytes;
        int i, n, pos, neg, acl;
-       char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
+       char user[128] = "[Unknown]"; /* Be sure to adjust sscanf()s below if length is changed... */
 
        old_offset = offset;
        bytes = tvb_get_ntohl(tvb, offset);
index 3a8dfb6f9226a4e726ccde0a2935db437e9c6663..5273846564dc456c2f3f0c41ba4870c528d9c845 100644 (file)
@@ -703,7 +703,7 @@ dissect_aim_snac(tvbuff_t *tvb, packet_info *pinfo, int offset,
        offset += 4;
 
 
-       if( aim_tree )
+       if( aim_tree && subtype != NULL )
        {
                offset = orig_offset;
                ti1 = proto_tree_add_text(aim_tree, tvb, 6, 10,
@@ -755,7 +755,7 @@ dissect_aim_snac(tvbuff_t *tvb, packet_info *pinfo, int offset,
        if (family)
                col_set_str(pinfo->cinfo, COL_PROTOCOL, family->name);
 
-       if(subtype && family)
+       if(subtype != NULL && family != NULL)
        {
                col_set_str(pinfo->cinfo, COL_INFO, family->name);
                col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", subtype->name);
@@ -770,7 +770,7 @@ dissect_aim_snac(tvbuff_t *tvb, packet_info *pinfo, int offset,
                col_append_fstr(pinfo->cinfo, COL_INFO, ", Subtype: 0x%04x", subtype_id);
        }
 
-       if(aim_tree && family)
+       if(aim_tree && family != NULL)
        {
                proto_item *ti = proto_tree_add_item(root_tree, family->proto_id, subtvb, 0, -1, FALSE);
                family_tree = proto_item_add_subtree(ti, family->ett);
@@ -778,7 +778,7 @@ dissect_aim_snac(tvbuff_t *tvb, packet_info *pinfo, int offset,
                        proto_item_append_text(ti, ", %s", subtype->name);
        }
 
-       if(tvb_length_remaining(tvb, offset) > 0 && subtype && subtype->dissector)
+       if(tvb_length_remaining(tvb, offset) > 0 && subtype != NULL && subtype->dissector)
        {
                subtype->dissector(subtvb, pinfo, family_tree);
        }
index 38ff09a51bc560c68a9cfb80597fb89bdb9d761f..3e771ca2407c10f14e1222553a5ac17516115674 100644 (file)
@@ -1505,7 +1505,7 @@ static void dissect_alcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
                 break;
         }
 
-        if (leg && ( (! leg->msgs) || leg->msgs->last->framenum < pinfo->fd->num ) ) {
+        if (leg != NULL && ( (! leg->msgs) || leg->msgs->last->framenum < pinfo->fd->num ) ) {
             alcap_msg_data_t* msg = se_alloc(sizeof(alcap_msg_data_t));
             msg->msg_type = msg_info->msg_type;
             msg->framenum = pinfo->fd->num;
index 99fa779dc68b0b464a7643c238b5b2a1144b1074..974c9b33fdaf5292140311422783718c2ad4e0bb 100644 (file)
@@ -601,8 +601,8 @@ dissect_amr_name(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree)
        amr_capability_t *ftr = NULL; 
 
        actx = get_asn1_ctx(pinfo->private_data);
-       DISSECTOR_ASSERT(actx);
-       if (tree) {
+       DISSECTOR_ASSERT(actx != NULL);
+       if (tree && actx != NULL) {
                ftr = find_cap(pinfo->match_string);
                if (ftr) {
                        proto_item_append_text(actx->created_item, " - %s", ftr->name);
index 8c5345097385186d06b67673d0db9471437592ca..14f81191a89da166a8073e16d7885f57535aa603 100644 (file)
@@ -657,7 +657,7 @@ static int proto_a_dtap = -1;
 const ext_value_string_t *ansi_a_bsmap_strings = NULL;
 const ext_value_string_t *ansi_a_dtap_strings = NULL;
 const ext_value_string_t *ansi_a_elem_1_strings = NULL;
-static guint ansi_a_elem_1_max = 0;
+static gint ansi_a_elem_1_max = 0;
 
 static int ansi_a_tap = -1;
 
@@ -8729,7 +8729,7 @@ elem_tlv(tvbuff_t *tvb, proto_tree *tree, elem_idx_t idx, guint32 offset, guint
     curr_offset = offset;
     consumed = 0;
 
-    if ((unsigned) idx >= ansi_a_elem_1_max-1)
+    if (idx < 0 || idx >= ansi_a_elem_1_max-1)
     {
         /* Unknown index, skip the element */
         return tvb_length_remaining(tvb, offset) ;
@@ -8812,7 +8812,7 @@ elem_tv(tvbuff_t *tvb, proto_tree *tree, elem_idx_t idx, guint32 offset, const g
     curr_offset = offset;
     consumed = 0;
 
-    if ((unsigned) idx >= ansi_a_elem_1_max-1)
+    if (idx < 0 || idx >= ansi_a_elem_1_max-1)
     {
         /* Unknown index, skip the element */
         return tvb_length_remaining(tvb, offset) ;
@@ -8886,7 +8886,7 @@ elem_t(tvbuff_t *tvb, proto_tree *tree, elem_idx_t idx, guint32 offset, const gc
     curr_offset = offset;
     consumed = 0;
 
-    if ((unsigned)idx >= ansi_a_elem_1_max-1)
+    if (idx < 0 || idx >= ansi_a_elem_1_max-1)
     {
         /* Unknown index, skip the element */
         return tvb_length_remaining(tvb, offset) ;
@@ -8924,7 +8924,7 @@ elem_lv(tvbuff_t *tvb, proto_tree *tree, elem_idx_t idx, guint32 offset, guint l
     curr_offset = offset;
     consumed = 0;
 
-    if ((unsigned) idx >= ansi_a_elem_1_max-1)
+    if (idx < 0 || idx >= ansi_a_elem_1_max-1)
     {
         /* Unknown index, skip the element */
         return tvb_length_remaining(tvb, offset) ;
@@ -8992,7 +8992,7 @@ elem_v(tvbuff_t *tvb, proto_tree *tree, elem_idx_t idx, guint32 offset)
     curr_offset = offset;
     consumed = 0;
 
-    if ((unsigned) idx >= ansi_a_elem_1_max-1)
+    if (idx < 0 || idx >= ansi_a_elem_1_max-1)
     {
         /* Unknown index, skip the element */
         return tvb_length_remaining(tvb, offset) ;
@@ -11614,7 +11614,7 @@ dissect_cdma2000_a1_elements(tvbuff_t *tvb, _U_ packet_info *pinfo, proto_tree *
     guint32     curr_offset;
     guint32     consumed;
     guint       curr_len;
-    guint       idx;
+    gint        idx;
     guint8      oct;
 
     curr_offset = offset;
index f310cd37bfa38b63e2a3afa250a2df0ad14d60c4..a71ef0e919e825ade3831baf5039092f47a5d62c 100644 (file)
@@ -305,7 +305,7 @@ dissect_ata_pdu(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset,
     }
   } else {
     proto_tree_add_item(tree, hf_aoe_astatus, tvb, offset, 1, FALSE);
-    if(ata_info && ata_info->request_frame){
+    if(ata_info != NULL && ata_info->request_frame){
       /* we dont know what command it was unless we saw the request_frame */
       tmp_item=proto_tree_add_uint(tree, hf_aoe_acmd, tvb, 0, 0, ata_info->cmd);
       PROTO_ITEM_SET_GENERATED(tmp_item);