Fix vector index range.
authorPeter D. Barnes, Jr. <barnes26@llnl.gov>
Fri, 24 May 2013 12:50:44 -0700
changeset 9812 69671bec393b
parent 9811 a573c11fddce
child 9813 16f65595bdf8
Fix vector index range.
src/network/test/packet-test-suite.cc
utils/coverity-report.sh
--- a/src/network/test/packet-test-suite.cc	Fri May 24 12:50:02 2013 -0700
+++ b/src/network/test/packet-test-suite.cc	Fri May 24 12:50:44 2013 -0700
@@ -20,6 +20,7 @@
 #include "ns3/packet.h"
 #include "ns3/packet-tag-list.h"
 #include "ns3/test.h"
+#include "ns3/unused.h"
 #include <limits>     // std:numeric_limits
 #include <string>
 #include <cstdarg>
@@ -506,7 +507,11 @@
   ATestTag<4> t4 (1); \
   ATestTag<5> t5 (1); \
   ATestTag<6> t6 (1); \
-  ATestTag<7> t7 (1)
+  ATestTag<7> t7 (1); \
+  const int tagLast = 7;  /* length of ref PacketTagList */ \
+  NS_UNUSED (tagLast) /* silence warnings */
+ 
+  
   
 void
 PacketTagListTest::CheckRefList (const PacketTagList & ptl,
@@ -672,7 +677,8 @@
   { // Timing
     std::cout << GetName () << "add+remove timing" << std::endl;
     int flm = std::numeric_limits<int>::max ();
-    for (int i = 0; i < 100; ++i) {
+    const int nIterations = 100;
+    for (int i = 0; i < nIterations; ++i) {
       int now = AddRemoveTime ();
       if (now < flm) flm = now;
     }
@@ -681,9 +687,10 @@
               << std::endl;
     
     std::cout << GetName () << "remove timing" << std::endl;
-    std::vector <int> rmn (7, std::numeric_limits<int>::max ());
-    for (int i = 0; i < 100; ++i) {
-      for (int j = 1; j < 8; ++j) {
+    // tags numbered from 1, so add one for (unused) entry at 0
+    std::vector <int> rmn (tagLast + 1, std::numeric_limits<int>::max ());
+    for (int i = 0; i < nIterations; ++i) {
+      for (int j = 1; j <= tagLast; ++j) {
 	int now = 0;
 	switch (j) {
         case 7:  now = RemoveTime (ref, t7);  break;
@@ -698,7 +705,7 @@
 	if (now < rmn[j]) rmn[j] = now;
       } // for tag j
     } // for iteration i
-    for (int j = 7; j > 0; --j) {
+    for (int j = tagLast; j > 0; --j) {
       std::cout << GetName () << "min remove time: t"
 		<< j          << ": "
 		<< std::setw (8) << rmn[j]     << " ticks"
--- a/utils/coverity-report.sh	Fri May 24 12:50:02 2013 -0700
+++ b/utils/coverity-report.sh	Fri May 24 12:50:44 2013 -0700
@@ -39,7 +39,7 @@
 }
 function doo ()
 {
-    say "$"$*
+    say "$ "$*
     $* 2>&1 | tee -a $logf
 }
 
@@ -68,7 +68,8 @@
 
 repoversion="$(basename $(dirname $PWD))@$(hg id -i)"
 
-description="Coverity mods"
+# curl complains if this contains white space
+description="Coverity-mods"
     
 doo curl \
      --form file=@$tarf \