ctf: make magic numbers optional
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 10 Jun 2015 19:34:59 +0000 (15:34 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 11 Jun 2015 18:29:22 +0000 (14:29 -0400)
Change-Id: If86103a84c939e551889359e3d669c5a3cabb8c7
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/49962
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/CTFStrings.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java

index 6ddf16b135ea1cfb78dac5cd68bd63c05710f8c4..d15077c370319f0c4a9906e673af6abd14e04297 100644 (file)
@@ -91,4 +91,11 @@ public interface CTFStrings {
      * @since 1.0
      */
     String CONTENT_SIZE = "content_size";
+
+    /**
+     * Magic number
+     *
+     * @since 1.0
+     */
+    String MAGIC = "magic";
 }
index f12e98bf56506d77f18c575e8aabd85ace319a11..eff931373ffd8a9d4348891ae12a0bc2bfcaa3d6 100644 (file)
@@ -34,6 +34,7 @@ import java.util.TreeSet;
 import java.util.UUID;
 
 import org.eclipse.tracecompass.ctf.core.CTFException;
+import org.eclipse.tracecompass.ctf.core.CTFStrings;
 import org.eclipse.tracecompass.ctf.core.event.CTFCallsite;
 import org.eclipse.tracecompass.ctf.core.event.CTFClock;
 import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
@@ -523,10 +524,12 @@ public class CTFTrace implements IDefinitionScope {
     }
 
     private static void validateMagicNumber(StructDefinition packetHeaderDef) throws CTFException {
-        IntegerDefinition magicDef = (IntegerDefinition) packetHeaderDef.lookupDefinition("magic"); //$NON-NLS-1$
-        int magic = (int) magicDef.getValue();
-        if (magic != Utils.CTF_MAGIC) {
-            throw new CTFException("CTF magic mismatch"); //$NON-NLS-1$
+        IntegerDefinition magicDef = (IntegerDefinition) packetHeaderDef.lookupDefinition(CTFStrings.MAGIC);
+        if (magicDef != null) {
+            int magic = (int) magicDef.getValue();
+            if (magic != Utils.CTF_MAGIC) {
+                throw new CTFException("CTF magic mismatch"); //$NON-NLS-1$
+            }
         }
     }
 
@@ -593,8 +596,8 @@ public class CTFTrace implements IDefinitionScope {
         }
 
         /*
-         * If the stream we try to add has no key set, it must be the only
-         * one. Thus, if the streams container is not empty, it is not valid.
+         * If the stream we try to add has no key set, it must be the only one.
+         * Thus, if the streams container is not empty, it is not valid.
          */
         if ((!stream.isIdSet()) && (!fStreams.isEmpty())) {
             throw new ParseException("Stream without id with multiple streams"); //$NON-NLS-1$
This page took 0.031154 seconds and 5 git commands to generate.