Skip to content

Commit

Permalink
Remove unneed null checks
Browse files Browse the repository at this point in the history
A recent JDT update seems to have extended the null flow analysis
to consider the case where assigning an Integer from an int makes
it effectively non-null.

This points out that we were doing some redundant null checks.

Change-Id: Ie222b519f02e45584ae4f47381025fd28a8f6423
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/46967
Reviewed-by: Hudson CI
  • Loading branch information
Alexandre Montplaisir committed May 6, 2015
1 parent a09f253 commit c74fb44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,20 @@ protected void eventHandle(@Nullable ITmfEvent event) {
* We add the time from startTime until now to the cumulative
* time of the thread
*/
if (startTime != null) {
ITmfStateValue value = ss.queryOngoingState(cumulativeTimeQuark);

/*
* Modify cumulative time for this CPU/TID combo: The total
* time changes when the process is scheduled out. Nothing
* happens when the process is scheduled in.
*/
long prevCumulativeTime = Math.max(0, value.unboxLong());
long newCumulativeTime = prevCumulativeTime + (ts - startTime);

value = TmfStateValue.newValueLong(newCumulativeTime);
ss.modifyAttribute(ts, value, cumulativeTimeQuark);
fLastStartTimes.put(cpu, ts);
}
ITmfStateValue value = ss.queryOngoingState(cumulativeTimeQuark);

/*
* Modify cumulative time for this CPU/TID combo: The total time
* changes when the process is scheduled out. Nothing happens
* when the process is scheduled in.
*/
long prevCumulativeTime = Math.max(0, value.unboxLong());
long newCumulativeTime = prevCumulativeTime + (ts - startTime);

value = TmfStateValue.newValueLong(newCumulativeTime);
ss.modifyAttribute(ts, value, cumulativeTimeQuark);
fLastStartTimes.put(cpu, ts);

} catch (AttributeNotFoundException e) {
Activator.getDefault().logError("Attribute not found in LttngKernelCpuStateProvider", e); //$NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,8 @@ protected void eventHandle(@Nullable ITmfEvent event) {
* prev_state, string next_comm, int32 next_tid, int32 next_prio
*/
{
Integer prevTid = ((Long) content.getField(fLayouts.get(event.getTrace()).fieldPrevTid()).getValue()).intValue();
Integer nextTid = ((Long) content.getField(fLayouts.get(event.getTrace()).fieldNextTid()).getValue()).intValue();

if (prevTid == null || nextTid == null) {
break;
}
int prevTid = ((Long) content.getField(fLayouts.get(event.getTrace()).fieldPrevTid()).getValue()).intValue();
int nextTid = ((Long) content.getField(fLayouts.get(event.getTrace()).fieldNextTid()).getValue()).intValue();

if (host.isGuest()) {
/* Get the event's CPU */
Expand Down

0 comments on commit c74fb44

Please sign in to comment.