Resolve more FindBugs warnings. These changes are all no-ops.

This commit is contained in:
Mike Hearn 2013-02-22 12:05:29 +01:00
parent 3ae65f7a2f
commit 6b684a6dc6
7 changed files with 42 additions and 30 deletions

View File

@ -186,10 +186,19 @@ public class BloomFilter extends Message {
int k1 = 0;
switch(object.length & 3)
{
case 3: k1 ^= (object[numBlocks + 2] & 0xff) << 16;
case 2: k1 ^= (object[numBlocks + 1] & 0xff) << 8;
case 1: k1 ^= (object[numBlocks] & 0xff);
case 3:
k1 ^= (object[numBlocks + 2] & 0xff) << 16;
// Fall through.
case 2:
k1 ^= (object[numBlocks + 1] & 0xff) << 8;
// Fall through.
case 1:
k1 ^= (object[numBlocks] & 0xff);
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
// Fall through.
default:
// Do nothing.
break;
};
// finalization

View File

@ -507,7 +507,7 @@ public class ECKey implements Serializable {
}
// Compressed keys require you to know an extra bit of data about the y-coord as there are two possibilities.
// So it's encoded in the recId.
ECPoint R = decompressKey(x, recId % 2 == 1);
ECPoint R = decompressKey(x, (recId & 1) == 1);
// 1.4. If nR != point at infinity, then do another iteration of Step 1 (callers responsibility).
if (!R.multiply(n).isInfinity())
return null;

View File

@ -344,7 +344,7 @@ public class NetworkParameters implements Serializable {
* Returns true if the block height is either not a checkpoint, or is a checkpoint and the hash matches.
*/
public boolean passesCheckpoint(int height, Sha256Hash hash) {
Sha256Hash checkpointHash = checkpoints.get(new Integer(height));
Sha256Hash checkpointHash = checkpoints.get(Integer.valueOf(height));
if (checkpointHash != null)
return checkpointHash.equals(hash);
return true;
@ -356,7 +356,7 @@ public class NetworkParameters implements Serializable {
* @return
*/
public boolean isCheckpoint(int height) {
Sha256Hash checkpointHash = checkpoints.get(new Integer(height));
Sha256Hash checkpointHash = checkpoints.get(Integer.valueOf(height));
if (checkpointHash != null)
return true;
return false;

View File

@ -726,6 +726,7 @@ public class Script {
sigOps += getOpNValue(lastOpCode);
else
sigOps += 20;
break;
default:
break;
}
@ -1181,6 +1182,8 @@ public class Script {
else
numericOPnum = BigInteger.ONE;
break;
default:
throw new AssertionError("Unreachable");
}
stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPnum, false)));

View File

@ -39,7 +39,7 @@ public class StoredTransactionOutput implements Serializable {
/** Which output of that transaction we are talking about. */
private long index;
/** arbitrary value lower than -{@link NetworkParameters.spendableCoinbaseDepth}
/** arbitrary value lower than -{@link NetworkParameters#spendableCoinbaseDepth}
* (not too low to get overflows when we do blockHeight - NONCOINBASE_HEIGHT, though) */
private static final int NONCOINBASE_HEIGHT = -200;
/** The height of the creating block (for coinbases, NONCOINBASE_HEIGHT otherwise) */
@ -71,7 +71,8 @@ public class StoredTransactionOutput implements Serializable {
public StoredTransactionOutput(InputStream in) throws IOException {
byte[] valueBytes = new byte[8];
in.read(valueBytes, 0, 8);
if (in.read(valueBytes, 0, 8) != 8)
throw new EOFException();
value = BigInteger.valueOf(Utils.readInt64(valueBytes, 0));
int scriptBytesLength = ((in.read() & 0xFF) << 0) |
@ -154,18 +155,18 @@ public class StoredTransactionOutput implements Serializable {
public void serializeToStream(OutputStream bos) throws IOException {
Utils.uint64ToByteStreamLE(value, bos);
bos.write((int) (0xFF & (scriptBytes.length >> 0)));
bos.write((int) (0xFF & (scriptBytes.length >> 8)));
bos.write((int) (0xFF & (scriptBytes.length >> 16)));
bos.write((int) (0xFF & (scriptBytes.length >> 24)));
bos.write(0xFF & scriptBytes.length >> 0);
bos.write(0xFF & scriptBytes.length >> 8);
bos.write(0xFF & (scriptBytes.length >> 16));
bos.write(0xFF & (scriptBytes.length >> 24));
bos.write(scriptBytes);
bos.write(hash.getBytes());
Utils.uint32ToByteStreamLE(index, bos);
bos.write((int) (0xFF & (height >> 0)));
bos.write((int) (0xFF & (height >> 8)));
bos.write((int) (0xFF & (height >> 16)));
bos.write((int) (0xFF & (height >> 24)));
bos.write(0xFF & (height >> 0));
bos.write(0xFF & (height >> 8));
bos.write(0xFF & (height >> 16));
bos.write(0xFF & (height >> 24));
}
}

View File

@ -57,19 +57,19 @@ public class TransactionOutputChanges {
public void serializeToStream(OutputStream bos) throws IOException {
int numOutsCreated = txOutsCreated.size();
bos.write((int) (0xFF & (numOutsCreated >> 0)));
bos.write((int) (0xFF & (numOutsCreated >> 8)));
bos.write((int) (0xFF & (numOutsCreated >> 16)));
bos.write((int) (0xFF & (numOutsCreated >> 24)));
bos.write(0xFF & (numOutsCreated >> 0));
bos.write(0xFF & (numOutsCreated >> 8));
bos.write(0xFF & (numOutsCreated >> 16));
bos.write(0xFF & (numOutsCreated >> 24));
for (StoredTransactionOutput output : txOutsCreated) {
output.serializeToStream(bos);
}
int numOutsSpent = txOutsSpent.size();
bos.write((int) (0xFF & (numOutsSpent >> 0)));
bos.write((int) (0xFF & (numOutsSpent >> 8)));
bos.write((int) (0xFF & (numOutsSpent >> 16)));
bos.write((int) (0xFF & (numOutsSpent >> 24)));
bos.write(0xFF & (numOutsSpent >> 0));
bos.write(0xFF & (numOutsSpent >> 8));
bos.write(0xFF & (numOutsSpent >> 16));
bos.write(0xFF & (numOutsSpent >> 24));
for (StoredTransactionOutput output : txOutsSpent) {
output.serializeToStream(bos);
}

View File

@ -18,7 +18,6 @@ package com.google.bitcoin.store;
import com.google.bitcoin.core.*;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -291,7 +290,7 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
count++;
}
rs.close();
System.out.printf("Setings size: %d, count: %d, average size: %f\n", size, count, (double)size/count);
System.out.printf("Settings size: %d, count: %d, average size: %f%n", size, count, (double)size/count);
totalSize += size; size = 0; count = 0;
rs = s.executeQuery("SELECT chainWork, header FROM headers");
@ -303,7 +302,7 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
count++;
}
rs.close();
System.out.printf("Headers size: %d, count: %d, average size: %f\n", size, count, (double)size/count);
System.out.printf("Headers size: %d, count: %d, average size: %f%n", size, count, (double)size/count);
totalSize += size; size = 0; count = 0;
rs = s.executeQuery("SELECT txOutChanges, transactions FROM undoableBlocks");
@ -320,7 +319,7 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
count++;
}
rs.close();
System.out.printf("Undoable Blocks size: %d, count: %d, average size: %f\n", size, count, (double)size/count);
System.out.printf("Undoable Blocks size: %d, count: %d, average size: %f%n", size, count, (double)size/count);
totalSize += size; size = 0; count = 0;
rs = s.executeQuery("SELECT id FROM openOutputsIndex");
@ -331,7 +330,7 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
count++;
}
rs.close();
System.out.printf("Open Outputs Index size: %d, count: %d, size in id indexes: %d\n", size, count, count * 8);
System.out.printf("Open Outputs Index size: %d, count: %d, size in id indexes: %d%n", size, count, count * 8);
totalSize += size; size = 0; count = 0;
long scriptSize = 0;
@ -345,7 +344,7 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
count++;
}
rs.close();
System.out.printf("Open Outputs size: %d, count: %d, average size: %f, average script size: %f (%d in id indexes)\n",
System.out.printf("Open Outputs size: %d, count: %d, average size: %f, average script size: %f (%d in id indexes)%n",
size, count, (double)size/count, (double)scriptSize/count, count * 8);
totalSize += size;