SPICE: fix ... defined but not used [-Werror=unused-const-variable] found by gcc6
[metze/wireshark/wip.git] / epan / reassemble_test.c
index 8d9a9b55159bd52691784e7222bc47a96c50ab4c..77d27d9240a8ff4666e44875b3d967c68693b85a 100644 (file)
  *      env                               \
  *        G_DEBUG=gc-friendly             \
  *        G_SLICE=always-malloc           \
- *        WIRESHARK_DEBUG_EP_NO_CHUNKS=1  \
- *        WIRESHARK_DEBUG_SE_NO_CHUNKS=1  \
- *        WIRESHARK_DEBUG_SE_USE_CANARY=1 \
- *        WIRESHARK_EP_VERIFY_POINTERS=1  \
- *        WIRESHARK_SE_VERIFY_POINTERS=1  \
  *      valgrind --leak-check=full --show-reachable=yes ./reassemble_test
  *
  *  2. Debug functions have been added which will print information
@@ -58,7 +53,6 @@
 
 #include "config.h"
 
-#include <epan/emem.h>
 #include <epan/packet.h>
 #include <epan/packet_info.h>
 #include <epan/proto.h>
@@ -213,7 +207,7 @@ test_simple_fragment_add_seq(void)
 
     printf("Starting test test_simple_fragment_add_seq\n");
 
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                              0, 50, TRUE, 0);
 
@@ -230,14 +224,14 @@ test_simple_fragment_add_seq(void)
 
     /* start another pdu (just to confuse things) */
     pinfo.fd->flags.visited = 0;
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 15, &pinfo, 13, NULL,
                              0, 60, TRUE, 0);
     ASSERT_EQ(2,g_hash_table_size(test_reassembly_table.fragment_table));
     ASSERT_EQ(NULL,fd_head);
 
     /* now we add the terminal fragment of the first datagram */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              2, 60, FALSE, 0);
 
@@ -246,7 +240,7 @@ test_simple_fragment_add_seq(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* finally, add the missing fragment */
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 15, &pinfo, 12, NULL,
                              1, 60, TRUE, 0);
 
@@ -296,7 +290,7 @@ test_simple_fragment_add_seq(void)
     /* what happens if we revisit the packets now? */
     fdh0 = fd_head;
     pinfo.fd->flags.visited = 1;
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                              0, 50, TRUE, 0);
     /*
@@ -306,12 +300,12 @@ test_simple_fragment_add_seq(void)
      */
     ASSERT_EQ(fdh0,fd_head);
 
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              2, 60, FALSE, 0);
     ASSERT_EQ(fdh0,fd_head);
 
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 15, &pinfo, 12, NULL,
                              1, 60, TRUE, 0);
     ASSERT_EQ(fdh0,fd_head);
@@ -346,7 +340,7 @@ test_fragment_add_seq_partial_reassembly(void)
     /* generally it's probably fair to assume that we will be called with
      * more_frags=FALSE.
      */
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                              0, 50, FALSE, 0);
 
@@ -380,7 +374,7 @@ test_fragment_add_seq_partial_reassembly(void)
      * check on the state of things), we're going to set the more_frags flag
      * here
      */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 0, &pinfo, 12, NULL,
                              1, 40, TRUE, 0);
 
@@ -418,7 +412,7 @@ test_fragment_add_seq_partial_reassembly(void)
 
     /* Another copy of the second segment.
      */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 0, &pinfo, 12, NULL,
                              1, 40, TRUE, 0);
 
@@ -462,7 +456,7 @@ test_fragment_add_seq_partial_reassembly(void)
 
 
     /* have another go at wrapping things up */
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 20, &pinfo, 12, NULL,
                              2, 100, FALSE, 0);
 
@@ -522,7 +516,7 @@ test_fragment_add_seq_partial_reassembly(void)
 
     fragment_set_partial_reassembly(&test_reassembly_table, &pinfo, 12, NULL);
 
-    pinfo.fd->num = 5;
+    pinfo.num = 5;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 0, &pinfo, 12, NULL,
                              3, 40, FALSE, 0);
 
@@ -601,7 +595,7 @@ test_fragment_add_seq_duplicate_first(void)
 
     printf("Starting test test_fragment_add_seq_duplicate_first\n");
 
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                              0, 50, TRUE, 0);
 
@@ -609,7 +603,7 @@ test_fragment_add_seq_duplicate_first(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* Add the 2nd segment */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              1, 60, TRUE, 0);
 
@@ -618,7 +612,7 @@ test_fragment_add_seq_duplicate_first(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* Add the last fragment */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              2, 40, FALSE, 0);
 
@@ -626,7 +620,7 @@ test_fragment_add_seq_duplicate_first(void)
     ASSERT_NE(NULL,fd_head);
 
     /* Add the first fragment again */
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                              0, 50, TRUE, 0);
 
@@ -700,7 +694,7 @@ test_fragment_add_seq_duplicate_middle(void)
 
     printf("Starting test test_fragment_add_seq_duplicate_middle\n");
 
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                              0, 50, TRUE, 0);
 
@@ -708,7 +702,7 @@ test_fragment_add_seq_duplicate_middle(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* Add the 2nd segment */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              1, 60, TRUE, 0);
 
@@ -717,7 +711,7 @@ test_fragment_add_seq_duplicate_middle(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* Now, add the 2nd segment again (but in a different frame) */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              1, 60, TRUE, 0);
 
@@ -726,7 +720,7 @@ test_fragment_add_seq_duplicate_middle(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* finally, add the last fragment */
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              2, 40, FALSE, 0);
 
@@ -798,7 +792,7 @@ test_fragment_add_seq_duplicate_last(void)
 
     printf("Starting test test_fragment_add_seq_duplicate_last\n");
 
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                              0, 50, TRUE, 0);
 
@@ -806,7 +800,7 @@ test_fragment_add_seq_duplicate_last(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* Add the 2nd segment */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              1, 60, TRUE, 0);
 
@@ -815,7 +809,7 @@ test_fragment_add_seq_duplicate_last(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* Add the last fragment */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              2, 40, FALSE, 0);
 
@@ -823,7 +817,7 @@ test_fragment_add_seq_duplicate_last(void)
     ASSERT_NE(NULL,fd_head);
 
     /* Add the last fragment again */
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              2, 40, FALSE, 0);
 
@@ -898,7 +892,7 @@ test_fragment_add_seq_duplicate_conflict(void)
 
     printf("Starting test test_fragment_add_seq_duplicate_conflict\n");
 
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                              0, 50, TRUE, 0);
 
@@ -906,7 +900,7 @@ test_fragment_add_seq_duplicate_conflict(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* Add the 2nd segment */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              1, 60, TRUE, 0);
 
@@ -917,7 +911,7 @@ test_fragment_add_seq_duplicate_conflict(void)
     /* Now, add the 2nd segment again (but in a different frame and with
      * different data)
      */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 15, &pinfo, 12, NULL,
                              1, 60, TRUE, 0);
 
@@ -926,7 +920,7 @@ test_fragment_add_seq_duplicate_conflict(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* finally, add the last fragment */
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                              2, 40, FALSE, 0);
 
@@ -1010,7 +1004,7 @@ test_fragment_add_seq_check_work(fragment_head *(*fn)(reassembly_table *,
 {
     fragment_head *fd_head;
 
-    pinfo.fd -> num = 1;
+    pinfo.num = 1;
     fd_head=fn(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                0, 50, TRUE);
 
@@ -1019,7 +1013,7 @@ test_fragment_add_seq_check_work(fragment_head *(*fn)(reassembly_table *,
     ASSERT_EQ(NULL,fd_head);
 
     /* start another pdu (just to confuse things) */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fn(&test_reassembly_table, tvb, 15, &pinfo, 13, NULL,
                0, 60, TRUE);
     ASSERT_EQ(2,g_hash_table_size(test_reassembly_table.fragment_table));
@@ -1027,7 +1021,7 @@ test_fragment_add_seq_check_work(fragment_head *(*fn)(reassembly_table *,
     ASSERT_EQ(NULL,fd_head);
 
     /* add the terminal fragment of the first datagram */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fn(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                2, 60, FALSE);
 
@@ -1037,7 +1031,7 @@ test_fragment_add_seq_check_work(fragment_head *(*fn)(reassembly_table *,
     ASSERT_EQ(NULL,fd_head);
 
     /* finally, add the missing fragment */
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fn(&test_reassembly_table, tvb, 15, &pinfo, 12, NULL,
                1, 60, TRUE);
 
@@ -1107,7 +1101,7 @@ test_fragment_add_seq_check_1(void)
 
     printf("Starting test test_fragment_add_seq_check_1\n");
 
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq_check(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                                    1, 50, FALSE);
 
@@ -1116,7 +1110,7 @@ test_fragment_add_seq_check_1(void)
     ASSERT_EQ(NULL,fd_head);
 
     /* Now add the missing segment */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq_check(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                                    0, 60, TRUE);
 
@@ -1171,7 +1165,7 @@ test_fragment_add_seq_802_11_0(void)
     /* the 802.11 hack is that some non-fragmented datagrams have non-zero
      * fragment_number; test for this. */
 
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq_802_11(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                                     10, 50, FALSE);
 
@@ -1239,24 +1233,24 @@ static void
 test_fragment_add_seq_check_multiple(void) {
     fragment_head *fd_head;
 
-    pinfo.fd -> num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq_check(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                                    0, 50, TRUE);
 
     /* add the terminal fragment of the first datagram */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq_check(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                                    1, 20, FALSE);
 
     print_tables();
 
     /* Now: start a second datagram with the first fragment in frame #2 */
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq_check(&test_reassembly_table, tvb, 25, &pinfo, 12, NULL,
                0, 25, TRUE);
 
     /* add the terminal fragment of the second datagram */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq_check(&test_reassembly_table, tvb, 0, &pinfo, 12, NULL,
                                    1, 60, FALSE);
 
@@ -1281,7 +1275,7 @@ test_simple_fragment_add_seq_next(void)
 
     printf("Starting test test_simple_fragment_add_seq_next\n");
 
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head= fragment_add_seq_next(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                                   50, TRUE);
 
@@ -1300,7 +1294,7 @@ test_simple_fragment_add_seq_next(void)
 
     /* start another pdu (just to confuse things) */
     pinfo.fd->flags.visited = 0;
-    pinfo.fd->num = 2;
+    pinfo.num = 2;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 15, &pinfo, 13, NULL,
                                   60, TRUE);
     ASSERT_EQ(2,g_hash_table_size(test_reassembly_table.fragment_table));
@@ -1309,7 +1303,7 @@ test_simple_fragment_add_seq_next(void)
 
 
     /* now we add the terminal fragment of the first datagram */
-    pinfo.fd->num = 3;
+    pinfo.num = 3;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                                   60, FALSE);
 
@@ -1358,7 +1352,7 @@ test_missing_data_fragment_add_seq_next(void)
     printf("Starting test test_missing_data_fragment_add_seq_next\n");
 
     /* attempt to add a fragment which is longer than the data available */
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                                   DATA_LEN-9, TRUE);
 
@@ -1378,7 +1372,7 @@ test_missing_data_fragment_add_seq_next(void)
     ASSERT_EQ(NULL,fd_head->next);
 
     /* add another fragment (with all data present) */
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                                   60, FALSE);
 
@@ -1392,7 +1386,7 @@ test_missing_data_fragment_add_seq_next(void)
 
     /* check what happens when we revisit the packets */
     pinfo.fd->flags.visited = TRUE;
-    pinfo.fd->num = 1;
+    pinfo.num = 1;
 
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 10, &pinfo, 12, NULL,
                                   DATA_LEN-9, TRUE);
@@ -1409,7 +1403,7 @@ test_missing_data_fragment_add_seq_next(void)
     ASSERT_EQ(0,g_hash_table_size(test_reassembly_table.reassembled_table));
     ASSERT_EQ(NULL,fd_head);
 
-    pinfo.fd->num = 4;
+    pinfo.num = 4;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 5, &pinfo, 12, NULL,
                                   60, FALSE);
     ASSERT_EQ(1,g_hash_table_size(test_reassembly_table.fragment_table));
@@ -1429,7 +1423,7 @@ test_missing_data_fragment_add_seq_next_2(void)
 
     printf("Starting test test_missing_data_fragment_add_seq_next_2\n");
 
-    pinfo.fd->num = 11;
+    pinfo.num = 11;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 10, &pinfo, 24, NULL,
                                   50, TRUE);
 
@@ -1437,7 +1431,7 @@ test_missing_data_fragment_add_seq_next_2(void)
     ASSERT_EQ(0,g_hash_table_size(test_reassembly_table.reassembled_table));
     ASSERT_EQ(NULL,fd_head);
 
-    pinfo.fd->num = 12;
+    pinfo.num = 12;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 5, &pinfo, 24, NULL,
                                   DATA_LEN-4, FALSE);
 
@@ -1451,7 +1445,7 @@ test_missing_data_fragment_add_seq_next_2(void)
 
     /* check what happens when we revisit the packets */
     pinfo.fd->flags.visited = TRUE;
-    pinfo.fd->num = 11;
+    pinfo.num = 11;
 
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 10, &pinfo, 24, NULL,
                                   50, TRUE);
@@ -1463,7 +1457,7 @@ test_missing_data_fragment_add_seq_next_2(void)
     ASSERT_EQ(0,g_hash_table_size(test_reassembly_table.reassembled_table));
     ASSERT_EQ(NULL,fd_head);
 
-    pinfo.fd->num = 12;
+    pinfo.num = 12;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 5, &pinfo, 24, NULL,
                                   DATA_LEN-4, FALSE);
     ASSERT_EQ(0,g_hash_table_size(test_reassembly_table.fragment_table));
@@ -1482,7 +1476,7 @@ test_missing_data_fragment_add_seq_next_3(void)
 
     printf("Starting test test_missing_data_fragment_add_seq_next_3\n");
 
-    pinfo.fd->num = 20;
+    pinfo.num = 20;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 5, &pinfo, 30, NULL,
                                   DATA_LEN-4, FALSE);
 
@@ -1503,7 +1497,7 @@ test_missing_data_fragment_add_seq_next_3(void)
     /* revisiting the packet ought to produce the same result. */
     pinfo.fd->flags.visited = TRUE;
 
-    pinfo.fd->num = 20;
+    pinfo.num = 20;
     fd_head=fragment_add_seq_next(&test_reassembly_table, tvb, 5, &pinfo, 30, NULL,
                                   DATA_LEN-4, FALSE);
 
@@ -1553,9 +1547,6 @@ main(int argc _U_, char **argv _U_)
 #endif
     };
 
-    /* initialise stuff */
-    emem_init();
-
     /* a tvbuff for testing with */
     data = (char *)g_malloc(DATA_LEN);
     /* make sure it's full of stuff */
@@ -1567,8 +1558,8 @@ main(int argc _U_, char **argv _U_)
     /* other test stuff */
     pinfo.fd = &fd;
     fd.flags.visited = 0;
-    SET_ADDRESS(&pinfo.src,AT_IPv4,4,src);
-    SET_ADDRESS(&pinfo.dst,AT_IPv4,4,dst);
+    set_address(&pinfo.src,AT_IPv4,4,src);
+    set_address(&pinfo.dst,AT_IPv4,4,dst);
 
     /*************************************************************************/
     for(i=0; i < sizeof(tests)/sizeof(tests[0]); i++ ) {