Use vwr->STATS_LEN instead of numbers, and eliminate redundant checks.
authorGuy Harris <guy@alum.mit.edu>
Sat, 15 Mar 2014 01:36:36 +0000 (18:36 -0700)
committerGuy Harris <guy@alum.mit.edu>
Sat, 15 Mar 2014 01:37:03 +0000 (01:37 +0000)
Instead of throwing in 48 and 64 as numbers, use vwr->STATS_LEN to
indicate what the lengths are.  Yeah, it has to be fetched at run time,
but big deal.

That also shows that, as we've already rejected records whose size is
less than vwr->STATS_LEN, we don't have to check for that, so eliminate
those checks.

Change-Id: Id4822b3e5a02abfffb2da96a50999e36548a4279
Reviewed-on: https://code.wireshark.org/review/663
Reviewed-by: Guy Harris <guy@alum.mit.edu>
wiretap/vwr.c

index 2074f5d83efa39eed63bbcd2caa88917ced3b6d9..a05f09452e4db318f04ec1ad2eeaebac7e2a8295 100644 (file)
@@ -1078,12 +1078,9 @@ static int parse_s1_W_stats(vwr_t *vwr, struct wtap_pkthdr *phdr, guint8 *rec,
     float            phyRate;
 
 
-    if (rec_size<64)
-       rec_size = 64;
-
     /* Calculate the start of the statistics block in the buffer */
     /* Also get a bunch of fields from the stats block */
-    s_ptr    = &(rec[rec_size - 64]); /* point to it */
+    s_ptr    = &(rec[rec_size - vwr->STATS_LEN]); /* point to it */
     m_type   = s_ptr[1] & 0x7;
     f_tx     = !(s_ptr[1] & 0x8);
     octets   = pntoh16(&s_ptr[8]);
@@ -1254,13 +1251,10 @@ static int parse_s2_W_stats(vwr_t *vwr, struct wtap_pkthdr *phdr,
     guint64          delta_b;                             /* Used for calculating latency */
 
 
-    if (rec_size<48)
-       rec_size = 48;
-
     /* Calculate the start of the statistics block in the buffer */
     /* Also get a bunch of fields from the stats block */
     s_start_ptr = &(rec[0]);
-    s_trail_ptr = &(rec[rec_size - 48]);             /* point to it */
+    s_trail_ptr = &(rec[rec_size - vwr->STATS_LEN]);      /* point to it */
 
     /* L1p info is different for series III and for Series II - need to check */
     l1p_1 = s_start_ptr[0];