ctf: Fix some simple warnings in the code and tests
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 27 Apr 2012 17:11:21 +0000 (13:11 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 27 Apr 2012 17:13:26 +0000 (13:13 -0400)
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputReaderTimestampComparatorTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/ArrayDefinitionTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/DefinitionTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInput.java

index d54a02ba4981f5ce1f55335959ea4af3ba3516f8..6f078863f866e26149345a60113680f5859eefa8 100644 (file)
@@ -93,20 +93,8 @@ public class ReadTrace {
             System.out.print(val);
             System.out.print(", ");
         }
-        try {
-            testSeekIndex(trace);
-        } catch (CTFReaderException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-
-        try {
-            testSeekIndex(trace);
-        } catch (CTFReaderException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-
+        testSeekIndex(trace);
+        testSeekIndex(trace);
     }
 
     /**
@@ -119,7 +107,7 @@ public class ReadTrace {
         return Long.MIN_VALUE;
     }
 
-    public static void testSeekIndex(CTFTrace trace) throws CTFReaderException {
+    public static void testSeekIndex(CTFTrace trace) {
         CTFTraceReader fixture = new CTFTraceReader(trace);
         long rank = 300000L;
         long timeRank = 4281275394331L;
index 33ab674893304bfcb59c142af3933a20579d1ac2..ce33999fb3713715253eec1b6e8d068de27c1da9 100644 (file)
@@ -54,7 +54,7 @@ public class StreamInputReaderTimestampComparatorTest {
      * Run the StreamInputReaderTimestampComparator() constructor test.
      */
     @Test
-    public void testStreamInputReaderTimestampComparator_1() throws Exception {
+    public void testStreamInputReaderTimestampComparator_1() {
         assertNotNull(fixture);
     }
 
index 40963a9498db0a2856b0146cb1bbbea8236cc813..2f7bfdd5ac84f0a053b24d0f6d6cb816c9e92d0e 100644 (file)
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.IOException;
 import java.nio.channels.FileChannel;
 
 import org.eclipse.linuxtools.ctf.core.event.types.Definition;
@@ -72,11 +73,16 @@ public class StreamInputTest {
 
     /**
      * Run the FileChannel getFileChannel() method test.
+     * 
+     * @throws IOException 
      */
     @Test
-    public void testGetFileChannel() {
+    public void testGetFileChannel() throws IOException {
         FileChannel result = fixture.getFileChannel();
         assertNull(result);
+        if (result != null) {
+            result.close();
+        }
     }
 
     /**
index 3bdf3f9c08d746929b643117efcde35aa6100368..b2bb8017018553c8a3a3ca56301c5ca4981ba7b8 100644 (file)
@@ -107,7 +107,7 @@ public class ArrayDefinitionTest {
      * @param bits
      * @return
      */
-    private IntegerDefinition[] createIntDefs(int size, int bits) {
+    private static IntegerDefinition[] createIntDefs(int size, int bits) {
         IntegerDefinition[] defs = new IntegerDefinition[size];
         for (int i = 0; i < size; i++) {
 
index 7e172082f988b5a9b30e95bd9e01a79593498f49..b49eb82f76a303184e1a9d5a0af8769063b34e21 100644 (file)
@@ -62,7 +62,7 @@ public class DefinitionTest {
     }
 
     @Test
-    public void testToString() throws Exception {
+    public void testToString() {
         Definition fixture = new DefTest(null, "Hello"); //$NON-NLS-1$
         String result = fixture.toString();
 
index d29198f011402bf085b12cf3f8bf41244e7c85e5..e670f24c9648a8b455ceab004453874e48d1dbc9 100644 (file)
@@ -211,7 +211,7 @@ public class VariantDefinitionTest {
      * Run the SequenceDefinition lookupSequence(String) method test.
      */
     @Test
-    public void testLookupSequence_1() throws Exception {
+    public void testLookupSequence_1() {
         String name = ""; //$NON-NLS-1$
         SequenceDefinition result = fixture.lookupSequence(name);
         assertNull(result);
index fda56132c2e308aa48548cdc8e24b0900b362cb1..104bc6e59c1340aaf1d9a8de63596aece2a6d0e6 100644 (file)
@@ -67,7 +67,7 @@ public class CTFTraceReader {
     /**
      * Current event index
      */
-    private long index;
+    private long fIndex;
 
     private final long startIndex[];
 
@@ -100,7 +100,7 @@ public class CTFTraceReader {
          */
         this.startTime = prio.peek().getCurrentEvent().timestamp;
         this.endTime = this.startTime;
-        this.index = 0;
+        this.fIndex = 0;
         startIndex = new long[prio.size()];
         for (int i = 0; i < prio.size(); i++) {
             startIndex[i] = 0;
@@ -136,7 +136,7 @@ public class CTFTraceReader {
      * @return the index
      */
     public long getIndex() {
-        return index;
+        return fIndex;
     }
 
     // ------------------------------------------------------------------------
@@ -253,8 +253,8 @@ public class CTFTraceReader {
             if (!packetHasMoreEvents) {
                 int n = this.streamInputReaders.indexOf(top);
                 currentPacket.setIndexBegin(startIndex[n]);
-                currentPacket.setIndexEnd(index);
-                startIndex[n] = index + 1;
+                currentPacket.setIndexEnd(fIndex);
+                startIndex[n] = fIndex + 1;
             }
         }
         /*
@@ -271,7 +271,7 @@ public class CTFTraceReader {
             /*
              * increment the index
              */
-            index++;
+            fIndex++;
         }
         boolean hasMoreEvents = hasMoreEvents();
 
@@ -317,7 +317,7 @@ public class CTFTraceReader {
          * Remove all the trace readers from the priority queue
          */
         this.prio.clear();
-        index = 0;
+        fIndex = 0;
         long offset = 0;
         for (StreamInputReader streamInputReader : this.streamInputReaders) {
             /*
@@ -333,7 +333,7 @@ public class CTFTraceReader {
         for (StreamInputReader streamInputReader : this.streamInputReaders) {
             if (streamInputReader.getCurrentEvent() != null) {
                 this.prio.add(streamInputReader);
-                index = Math.max(index, streamInputReader.getPacketReader()
+                fIndex = Math.max(fIndex, streamInputReader.getPacketReader()
                         .getCurrentPacket().getIndexBegin()
                         + offset);
             }
@@ -396,7 +396,7 @@ public class CTFTraceReader {
                 this.advance();
             }
         }
-        this.index = pos;
+        this.fIndex = pos;
         return hasMoreEvents();
     }
 
index 7c4bf08676dcc0ff9d676d68bb40c3c0213f424a..4bcd872fff969687b4037bbcc45622c00784e2df 100644 (file)
@@ -214,7 +214,7 @@ public class StreamInputReader {
          */
         if (this.packetReader.getCurrentPacket() == null) {
             throw new CTFReaderException(
-                    "Current packet null in index seek, did you index your trace yet?");
+                    "Current packet null in index seek, did you index your trace yet?"); //$NON-NLS-1$
         }
         return this.packetReader.getCurrentPacket().getIndexBegin();
 
index 931b5d332a2aa257e533485734b18fdfac934401..7116c1be912f45292cc5fde2dd8482dacdd80173 100644 (file)
@@ -118,7 +118,6 @@ public class StreamInput implements IDefinitionScope {
     // Operations
     // ------------------------------------------------------------------------
 
-    @SuppressWarnings("unused")
     @Override
     public Definition lookupDefinition(String lookupPath) {
         /* TODO: lookup in different dynamic scopes is not supported yet. */
This page took 0.087506 seconds and 5 git commands to generate.