DESCRIPTION

ctf: Fix decoding of an invalid packet id type.

When an event id is not present, it is assumed to be zero.
Otherwise, it must be a _valid_ integer.

The current implementation accepts a "struct" as an id and map to the event id zero.

This fix throw an exception on an invalid id.

Change-Id: Iff6f6bd0173048dd3fb9b00f564948d7ebd55f4f
Signed-off-by: Jordon Obrien xxx@xxx.xxx


COMMENTS

author: Brenden Conley
date: 2013-11-30 05:20:29.000000000

Patch Set 1:

Build Started https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/4328/

-------------------------------------
author: Jordon Obrien
date: 2013-11-30 05:21:40.000000000

Patch Set 1:

This could be a good test to add in the ctf testsuite.

-------------------------------------
author: Brenden Conley
date: 2013-11-30 06:02:10.000000000

Patch Set 1: Verified+1

Build Successful 

https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/4328/ : SUCCESS

-------------------------------------
author: Tessa Dickson
date: 2013-11-30 12:04:42.000000000

Patch Set 1: Code-Review+1

lgtm.

Added tests into ctf-testsuite covering this in commit:

ec1a5be20155a85a892f141b186776baecadb95f

-------------------------------------
author: Tessa Dickson
date: 2013-11-30 12:09:30.000000000

Patch Set 1:

(1 comment)

actually, it's a lgtm wit nits.

Line:327, lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java -> it becomes a question of coding style preference, but I usually prefer:

if (errorcond1) {
   throw execption;
}
if (errorcon2) {
   throw exception;
}
if (specialcase) {
  handle special case;
  return;
}
handle normal case.

here you are doing:

if (specialcase) {
  handle special case;
} else if (normal case) {
  handle normal case;
} else {
  throw exception;
}

which is a bit much spaghetti-like IMO.

-------------------------------------
author: Jordon Obrien
date: 2013-12-01 19:23:46.000000000

Patch Set 1:

(1 comment)

Line:327, lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java -> I do not agree on this one. This pattern is like a case, with a default.

In a case like:

switch (x)
case a:
case b:
case c:
...
default:
}

You don't want to write

if (!a && !b &&!c ... && !z)
  throw error;
if (a)
   ...
if (b)
  ...

C/C++ don't let us write nice "dispatch" (only with if/else-if).
I prefer the match style like the one in OCaml.

The only thing I don't like is my case is an empty "if".

-------------------------------------
author: Braxton Mccarthy
date: 2013-12-02 17:15:59.000000000

Patch Set 1:

(1 comment)

Line:327, lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java -> You could simplify it to two clauses:

 if (idDef instanceof SimpleDataDefinition) {
   eventID = blahblah
 } else if (idDef != null) {
   throw new Exception;
 }
 // if idDef is null, eventID remains 0

If a value is null, it will return false to any "instanceof" check.

-------------------------------------
author: Braxton Mccarthy
date: 2013-12-02 21:37:38.000000000

Patch Set 1: Code-Review-1

Small suggestion.

-------------------------------------
