Skip to content

Commit

Permalink
Findbugs: Remove branches where reference cannot be null
Browse files Browse the repository at this point in the history
  • Loading branch information
sgothel committed Jul 8, 2014
1 parent a41db57 commit 815776c
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 34 deletions.
Expand Up @@ -186,8 +186,10 @@ protected BuildComposablePipeline(final int mode, final String outputDir, final
}

try {
// Keep assignment w/ null comparison for clarification.
// If no exception is thrown, return value is always non-null;
hasImmediateMode =
(classToComposeAround.getMethod("glBegin", new Class<?>[]{Integer.TYPE}) != null);
null != classToComposeAround.getMethod("glBegin", new Class<?>[]{Integer.TYPE});
} catch (final Exception e) {
}

Expand Down Expand Up @@ -388,7 +390,7 @@ public void emit(final Iterator<PlainMethod> methodsToWrap) throws IOException {
}
}

if (null != baseInterfaceClass && !clazzList.contains(baseInterfaceClass)) {
if ( !clazzList.contains(baseInterfaceClass) ) {
ifNames[i++] = baseInterfaceClass.getName();
clazzList.add(baseInterfaceClass);
}
Expand Down
8 changes: 4 additions & 4 deletions src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
Expand Up @@ -551,7 +551,7 @@ public void dumpShaderSource(final PrintStream out) {
out.println("<no shader source>");
return;
}
final int sourceCount = (null!=shaderSource)?shaderSource.length:0;
final int sourceCount = shaderSource.length;
final int shaderCount = (null!=shader)?shader.capacity():0;
for(int i=0; i<shaderCount; i++) {
out.println("");
Expand Down Expand Up @@ -601,7 +601,7 @@ public int insertShaderSource(final int shaderIdx, final String tag, final int f
if(0>shaderIdx || shaderIdx>=shaderCount) {
throw new IndexOutOfBoundsException("shaderIdx not within shader bounds [0.."+(shaderCount-1)+"]: "+shaderIdx);
}
final int sourceCount = (null!=shaderSource)?shaderSource.length:0;
final int sourceCount = shaderSource.length;
if(shaderIdx>=sourceCount) {
throw new IndexOutOfBoundsException("shaderIdx not within source bounds [0.."+(sourceCount-1)+"]: "+shaderIdx);
}
Expand Down Expand Up @@ -660,7 +660,7 @@ public int replaceInShaderSource(final String oldName, final String newName) {
final int oldNameLen = oldName.length();
final int newNameLen = newName.length();
int num = 0;
final int sourceCount = (null!=shaderSource)?shaderSource.length:0;
final int sourceCount = shaderSource.length;
for(int shaderIdx = 0; shaderIdx<sourceCount; shaderIdx++) {
final CharSequence[] src = shaderSource[shaderIdx];
for(int j=0; j<src.length; j++) {
Expand Down Expand Up @@ -706,7 +706,7 @@ public int insertShaderSource(final int shaderIdx, int position, final CharSeque
if(0>shaderIdx || shaderIdx>=shaderCount) {
throw new IndexOutOfBoundsException("shaderIdx not within shader bounds [0.."+(shaderCount-1)+"]: "+shaderIdx);
}
final int sourceCount = (null!=shaderSource)?shaderSource.length:0;
final int sourceCount = shaderSource.length;
if(shaderIdx>=sourceCount) {
throw new IndexOutOfBoundsException("shaderIdx not within source bounds [0.."+(sourceCount-1)+"]: "+shaderIdx);
}
Expand Down
Expand Up @@ -384,7 +384,7 @@ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final in
System.err.printf("XXX.Scale %d * [%f x %f]: %d x %d%n",
sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight);
}
if( hasDelta || fboDirty || isShapeDirty() || null == fbo || ( fbo != null && fbo.getNumSamples() != sampleCount[0] ) ) {
if( hasDelta || fboDirty || isShapeDirty() || null == fbo || fbo.getNumSamples() != sampleCount[0] ) {
// FIXME: rescale
final float minX = box.getMinX()-diffObjBorderWidth;
final float minY = box.getMinY()-diffObjBorderHeight;
Expand Down
Expand Up @@ -354,7 +354,7 @@ private boolean addVertex(final double[] coords, final Object vertexData) {
/* Create a new vertex and edge which immediately follow e
* in the ordering around the left face.
*/
if (Mesh.__gl_meshSplitEdge(e) == null) return false;
Mesh.__gl_meshSplitEdge(e);
e = e.Lnext;
}

Expand Down Expand Up @@ -396,11 +396,12 @@ private boolean flushCache() {
final CachedVertex[] v = cache;

mesh = Mesh.__gl_meshNewMesh();
if (mesh == null) return false;

for (int i = 0; i < cacheCount; i++) {
final CachedVertex vertex = v[i];
if (!addVertex(vertex.coords, vertex.data)) return false;
if (!addVertex(vertex.coords, vertex.data)) {
return false;
}
}
cacheCount = 0;
flushCacheOnNextVertex = false;
Expand Down
Expand Up @@ -173,10 +173,11 @@ int pqInsert(final Object keyNew) {
pqNodes[i] = new PQnode();
}
nodes = pqNodes;
/** Cannot be null
if (nodes == null) {
nodes = saveNodes; /* restore ptr to free upon return */
nodes = saveNodes; // restore ptr to free upon return
return Integer.MAX_VALUE;
}
} */

// pq->handles = (PQhandleElem *)memRealloc( pq->handles,(size_t)((pq->max + 1) * sizeof( pq->handles[0] )));
final PriorityQ.PQhandleElem[] pqHandles = new PriorityQ.PQhandleElem[max + 1];
Expand All @@ -185,10 +186,11 @@ int pqInsert(final Object keyNew) {
pqHandles[i] = new PQhandleElem();
}
handles = pqHandles;
/** cannot be null
if (handles == null) {
handles = saveHandles; /* restore ptr to free upon return */
handles = saveHandles; // restore ptr to free upon return
return Integer.MAX_VALUE;
}
} */
}

if (freeList == 0) {
Expand Down
Expand Up @@ -202,18 +202,19 @@ int pqInsert(final Object keyNew) {
}
curr = size;
if (++size >= max) {
final Object[] saveKey = keys;
// final Object[] saveKey = keys;

/* If the heap overflows, double its size. */
max <<= 1;
// pq->keys = (PQHeapKey *)memRealloc( pq->keys,(size_t)(pq->max * sizeof( pq->keys[0] )));
final Object[] pqKeys = new Object[max];
System.arraycopy( keys, 0, pqKeys, 0, keys.length );
keys = pqKeys;
/** Cannot be null
if (keys == null) {
keys = saveKey; /* restore ptr to free upon return */
keys = saveKey; // restore ptr to free upon return
return Integer.MAX_VALUE;
}
} */
}
assert curr != Integer.MAX_VALUE;
keys[curr] = keyNew;
Expand Down
1 change: 0 additions & 1 deletion src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java
Expand Up @@ -1237,7 +1237,6 @@ public boolean leq(final Object key1, final Object key2) {
return Geom.VertLeq(((GLUvertex) key1), (GLUvertex) key2);
}
});
if (pq == null) return false;

vHead = tess.mesh.vHead;
for (v = vHead.next; v != vHead; v = v.next) {
Expand Down
24 changes: 11 additions & 13 deletions src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
Expand Up @@ -571,19 +571,17 @@ public final void initStream(final URI streamLoc, final int vid, final int aid,

this.vid = vid;
this.aid = aid;
if ( this.streamLoc != null ) {
new Thread() {
public void run() {
try {
// StreamWorker may be used, see API-doc of StreamWorker
initStreamImpl(vid, aid);
} catch (final Throwable t) {
streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t);
changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized);
} // also initializes width, height, .. etc
}
}.start();
}
new Thread() {
public void run() {
try {
// StreamWorker may be used, see API-doc of StreamWorker
initStreamImpl(vid, aid);
} catch (final Throwable t) {
streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t);
changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized);
} // also initializes width, height, .. etc
}
}.start();
}
}
/**
Expand Down
Expand Up @@ -160,8 +160,8 @@ public final boolean update(final String info) {
} else {
// old info is OK
if( DEBUG ) {
final int mainThreadAppContextHash = null != mainThreadAppContext ? mainThreadAppContext.hashCode() : 0;
final int thisThreadAppContextHash = null != thisThreadAppContext ? thisThreadAppContext.hashCode() : 0;
final int mainThreadAppContextHash = mainThreadAppContext.hashCode();
final int thisThreadAppContextHash = thisThreadAppContext.hashCode();
System.err.println("Bug 1004[TGMapped "+tgMapped+"]: OK AppContext @ "+info+" on thread "+thread.getName()+" "+toHexString(thread.hashCode())+
": tg "+threadGroup.getName()+" "+toHexString(threadGroup.hashCode())+
" : appCtx [ this "+thisThreadAppContext+" "+toHexString(thisThreadAppContextHash)+
Expand Down
2 changes: 1 addition & 1 deletion src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
Expand Up @@ -298,7 +298,7 @@ public Boolean run(final long dpy) {
final PointerIconImpl pi = (PointerIconImpl)getPointerIcon();
final boolean res;
if( pointerVisible && null != pi ) {
setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.validatedHandle() : 0);
setPointerIcon0(dpy, getWindowHandle(), pi.validatedHandle());
res = true;
} else {
res = setPointerVisible0(dpy, getWindowHandle(), pointerVisible);
Expand Down

0 comments on commit 815776c

Please sign in to comment.