From ecb124610b9b491fe936ebe9a0a54d86d1ff360c Mon Sep 17 00:00:00 2001 From: Etienne Bergeron Date: Sat, 16 Nov 2013 22:57:50 -0500 Subject: [PATCH] ctf: Fix multiple coding style and typo issues while reading code. Change-Id: If63330f4c86e7cd87cf979e1709a81fb7c8958ab Signed-off-by: Etienne Bergeron Reviewed-on: https://git.eclipse.org/r/18541 Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Reviewed-by: Matthew Khouzam IP-Clean: Matthew Khouzam Tested-by: Hudson CI --- .../ctf/core/trace/CTFTraceReader.java | 24 +++++++------------ .../linuxtools/ctf/core/trace/Metadata.java | 6 ++--- .../ctf/core/trace/StreamInput.java | 11 ++++----- .../ctf/core/trace/StreamInputReader.java | 13 +++++----- .../ctf/core/event/EventDeclaration.java | 4 ++-- .../ctf/core/event/metadata/IOStructGen.java | 4 ++-- .../metadata/exceptions/ParseException.java | 2 +- .../core/trace/StreamInputPacketIndex.java | 9 ++++--- .../backends/historytree/HistoryTree.java | 2 +- .../tmf/core/ctfadaptor/CtfIterator.java | 6 ++--- .../core/ctfadaptor/CtfIteratorManager.java | 2 +- .../tmf/core/ctfadaptor/CtfLocation.java | 1 - .../tmf/core/ctfadaptor/CtfLocationInfo.java | 1 - .../tmf/core/ctfadaptor/CtfTmfLostEvent.java | 3 +-- 14 files changed, 39 insertions(+), 49 deletions(-) diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java index 812f6bd362..392900187b 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java @@ -257,9 +257,6 @@ public class CTFTraceReader { * @return True if an event was read. */ public boolean advance() { - /* - * Index the - */ /* * Remove the reader from the top of the priority queue. */ @@ -306,15 +303,16 @@ public class CTFTraceReader { } /** - * Seeks to a given timestamp It will go to the event just after the - * timestamp or the timestamp itself. if a if a trace is 10 20 30 40 and - * you're looking for 19, it'll give you 20, it you want 20, you'll get 20, - * if you want 21, you'll get 30. You want -inf, you'll get the first - * element, you want +inf, you'll get the end of the file with no events. + * Seeks to a given timestamp. It will seek to the nearest event greater or + * equal to timestamp. If a trace is [10 20 30 40] and you are looking for + * 19, it will give you 20. If you want 20, you will get 20, if you want 21, + * you will get 30. The value -inf will seek to the first element and the + * value +inf will seek to the end of the file (past the last event). * * @param timestamp * the timestamp to seek to - * @return true if the trace has more events following the timestamp + * @return true if there are events above or equal the seek timestamp, + * false if seek at the end of the trace (no valid event). */ public boolean seek(long timestamp) { /* @@ -330,19 +328,15 @@ public class CTFTraceReader { /* * Add it to the priority queue if there is a current event. */ - - } - for (StreamInputReader streamInputReader : this.streamInputReaders) { if (streamInputReader.getCurrentEvent() != null) { this.prio.add(streamInputReader); - } } return hasMoreEvents(); } /** - * gets the stream with the oldest event + * Gets the stream with the oldest event * * @return the stream with the oldest event */ @@ -405,7 +399,7 @@ public class CTFTraceReader { } /** - * gets the last event timestamp that was read. This is NOT necessarily the + * Gets the last event timestamp that was read. This is NOT necessarily the * last event in a trace, just the last one read so far. * * @return the last event diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java index 64e50669a3..7c9eed01c6 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java @@ -239,8 +239,8 @@ public class Metadata { private boolean isPacketBased(FileChannel metadataFileChannel) throws CTFReaderException { /* - * Create a ByteBuffer to read the TSDL magic number (default is big - * endian) + * Create a ByteBuffer to read the TSDL magic number (default is + * big-endian) */ ByteBuffer magicByteBuffer = ByteBuffer.allocate(Utils.TSDL_MAGIC_LEN); @@ -260,7 +260,7 @@ public class Metadata { return true; } - /* Try the same thing, but with little endian */ + /* Try the same thing, but with little-endian */ magicByteBuffer.order(ByteOrder.LITTLE_ENDIAN); magic = magicByteBuffer.getInt(0); diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java index d8ad3d6c0a..43d13ded88 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java @@ -115,7 +115,7 @@ public class StreamInput implements IDefinitionScope { } /** - * the common streamInput Index + * The common streamInput Index * * @return the stream input Index */ @@ -125,7 +125,7 @@ public class StreamInput implements IDefinitionScope { /** * Gets the filechannel of the streamInput. This is a limited Java - * ressource. + * resource. * * @return the filechannel */ @@ -143,7 +143,7 @@ public class StreamInput implements IDefinitionScope { } /** - * gets the last read timestamp of a stream. (this is not necessarily the + * Gets the last read timestamp of a stream. (this is not necessarily the * last time in the stream.) * * @return the last read timestamp @@ -164,7 +164,7 @@ public class StreamInput implements IDefinitionScope { } /** - * useless for streaminputs + * Useless for streaminputs */ @Override public String getPath() { @@ -352,7 +352,6 @@ public class StreamInput implements IDefinitionScope { throw new CTFReaderException( "CTF magic mismatch " + Integer.toHexString(magic) + " vs " + Integer.toHexString(Utils.CTF_MAGIC)); //$NON-NLS-1$//$NON-NLS-2$ } - } /* @@ -457,7 +456,7 @@ public class StreamInput implements IDefinitionScope { /* Read the end timestamp */ if (tsEnd != null) { - if( tsEnd == -1 ) { + if (tsEnd == -1) { tsEnd = Long.MAX_VALUE; } packetIndex.setTimestampEnd(tsEnd.longValue()); diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java index 0d6641ceb4..fdedf042f2 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java @@ -110,7 +110,7 @@ public class StreamInputReader { } /** - * gets the current packet context + * Gets the current packet context * * @return the current packet context (size, lost events and such) */ @@ -248,7 +248,6 @@ public class StreamInputReader { if (this.streamInput.addPacketHeaderIndex()) { packetIndex = getPacketSize() - 1; this.packetReader.setCurrentPacket(getPacket()); - } else { this.packetReader.setCurrentPacket(null); } @@ -268,7 +267,7 @@ public class StreamInputReader { /** * Changes the location of the trace file reader so that the current event - * is the first event with a timestamp greater than the given timestamp. + * is the first event with a timestamp greater or equal the given timestamp. * * @param timestamp * The timestamp to seek to. @@ -296,9 +295,11 @@ public class StreamInputReader { } /* - * Advance until A. we reached the end of the trace file (which means - * the given timestamp is after the last event), or B. we found the - * first event with a timestamp greater than the given timestamp. + * Advance until either of these conditions are met + *
    + *
  • reached the end of the trace file (the given timestamp is after the last event),
  • + *
  • found the first event with a timestamp greater or equal the given timestamp.
  • + *
*/ readNextEvent(); boolean done = (this.getCurrentEvent() == null); diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java index fa00efe121..27848e2ab6 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java @@ -171,7 +171,7 @@ public class EventDeclaration implements IEventDeclaration { } /** - * Sets the id of am event declaration + * Sets the id of an event declaration * * @param id * the id @@ -186,7 +186,7 @@ public class EventDeclaration implements IEventDeclaration { } /** - * Sets the stream of am event declaration + * Sets the stream of an event declaration * * @param stream * the stream diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java index 13f27d5f4a..d31d3634e1 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java @@ -72,7 +72,7 @@ public class IOStructGen { // ------------------------------------------------------------------------ /** - * Constuctor + * Constructor * * @param tree * the tree (ANTLR generated) with the parsed TSDL data. @@ -256,7 +256,7 @@ public class IOStructGen { for (CommonTree child : children) { String left; - /* this is a regex to find the leading and trailing quotes*/ + /* this is a regex to find the leading and trailing quotes */ final String regex = "^\"|\"$"; //$NON-NLS-1$ /* this is to replace the previous quotes with nothing... effectively deleting them */ final String nullString = ""; //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/ParseException.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/ParseException.java index 9b11d06271..7a56912fb2 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/ParseException.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/ParseException.java @@ -30,7 +30,7 @@ public class ParseException extends Exception { /** * Constructor * - * @param message (to be sent to logs + * @param message to be sent to logs */ public ParseException(String message) { super(message); diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java index 5532ad04fa..50c73ed313 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java @@ -84,26 +84,25 @@ public class StreamInputPacketIndex { public void addEntry(StreamInputPacketIndexEntry entry) throws CTFReaderException { assert (entry.getContentSizeBits() != 0); - assert (entry.getContentSizeBits() != 0); + /* Validate consistent entry. */ if (entry.getTimestampBegin() > entry.getTimestampEnd()) { throw new CTFReaderException("Packet begin timestamp is after end timestamp"); //$NON-NLS-1$ } + /* Validate entries are inserted in monotonic increasing timestamp order. */ if (!this.entries.isEmpty()) { if (entry.getTimestampBegin() < this.entries.lastElement() .getTimestampBegin()) { throw new CTFReaderException("Packets begin timestamp decreasing"); //$NON-NLS-1$ } } - this.entries.add(entry); } /** - * This method returns the first packet with the end timestamp greater - * or equal to the given timestamp. The returned packet is the first one - * that could include the timestamp. + * Returns the first PacketIndexEntry that could include the timestamp, + * that is the last packet with a begin timestamp smaller than the given timestamp. * * @param timestamp * The timestamp to look for. diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java index f5284048c6..fa2378b8a8 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java @@ -59,7 +59,7 @@ class HistoryTree { private final HT_IO treeIO; // ------------------------------------------------------------------------ - // Variable Fields (will change throughout the existance of the SHT) + // Variable Fields (will change throughout the existence of the SHT) // ------------------------------------------------------------------------ /** Latest timestamp found in the tree (at any given moment) */ diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java index 0f250a99c0..753ff29b38 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java @@ -85,7 +85,6 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext, } else { setUnknownLocation(); } - } /** @@ -157,7 +156,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext, this.advance(); } } else { - ret= false; + ret = false; } /* Seek the current location accordingly */ if (ret) { @@ -165,6 +164,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext, } else { curLocation = NULL_LOCATION; } + return ret; } @@ -233,7 +233,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext, @Override public void increaseRank() { /* Only increase the rank if it's valid */ - if(hasValidRank()) { + if (hasValidRank()) { curRank++; } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIteratorManager.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIteratorManager.java index 65fac21e59..afe436d121 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIteratorManager.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIteratorManager.java @@ -139,7 +139,7 @@ class CtfTraceManager { * * @param context * the context to look up - * @return the iterator refering to the context + * @return the iterator referring to the context */ public CtfIterator getIterator(final CtfTmfContext context) { /* diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java index 55acb6b584..c33d6c2e69 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java @@ -143,6 +143,5 @@ public final class CtfLocation extends TmfLocation { @Override public void serialize(ByteBuffer bufferOut) { getLocationInfo().serialize(bufferOut); - } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocationInfo.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocationInfo.java index 7a3c467815..cb974929af 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocationInfo.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocationInfo.java @@ -133,6 +133,5 @@ public class CtfLocationInfo implements Comparable { public void serialize(ByteBuffer bufferOut) { bufferOut.putLong(timestamp); bufferOut.putLong(index); - } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfLostEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfLostEvent.java index fb50df7014..05834bdb1e 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfLostEvent.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfLostEvent.java @@ -40,7 +40,7 @@ public class CtfTmfLostEvent extends CtfTmfEvent implements ITmfLostEvent { * @param fileName * The name of the trace file from which this event comes * @param cpu - * The CPU on which this event happend + * The CPU on which this event happened * @param declaration * The CTF Event Declaration object that created this event * @param timeRange @@ -75,5 +75,4 @@ public class CtfTmfLostEvent extends CtfTmfEvent implements ITmfLostEvent { return fNbLost; } - } -- 2.34.1