forked from I2P_Developers/i2p.i2p
about 20 findbugs fixes all over
This commit is contained in:
@ -14,30 +14,30 @@ abstract class CPUIDCPUInfo
|
||||
}
|
||||
public boolean hasMMX()
|
||||
{
|
||||
return (CPUID.getEDXCPUFlags() & 0x800000) >0; //EDX Bit 23
|
||||
return (CPUID.getEDXCPUFlags() & 0x800000) != 0; //EDX Bit 23
|
||||
}
|
||||
public boolean hasSSE(){
|
||||
return (CPUID.getEDXCPUFlags() & 0x2000000) >0; //EDX Bit 25
|
||||
return (CPUID.getEDXCPUFlags() & 0x2000000) != 0; //EDX Bit 25
|
||||
}
|
||||
public boolean hasSSE2()
|
||||
{
|
||||
return (CPUID.getEDXCPUFlags() & 0x4000000) >0; //EDX Bit 26
|
||||
return (CPUID.getEDXCPUFlags() & 0x4000000) != 0; //EDX Bit 26
|
||||
}
|
||||
public boolean hasSSE3()
|
||||
{
|
||||
return (CPUID.getEDXCPUFlags() & 0x1) >0; //ECX Bit 0
|
||||
return (CPUID.getEDXCPUFlags() & 0x1) != 0; //ECX Bit 0
|
||||
}
|
||||
public boolean hasSSE41()
|
||||
{
|
||||
return (CPUID.getEDXCPUFlags() & 0x80000) >0; //ECX Bit 19
|
||||
return (CPUID.getEDXCPUFlags() & 0x80000) != 0; //ECX Bit 19
|
||||
}
|
||||
public boolean hasSSE42()
|
||||
{
|
||||
return (CPUID.getEDXCPUFlags() & 0x100000) >0; //ECX Bit 20
|
||||
return (CPUID.getEDXCPUFlags() & 0x100000) != 0; //ECX Bit 20
|
||||
}
|
||||
public boolean hasSSE4A()
|
||||
{
|
||||
return (CPUID.getExtendedECXCPUFlags() & 0x40) >0; //Extended ECX Bit 6
|
||||
return (CPUID.getExtendedECXCPUFlags() & 0x40) != 0; //Extended ECX Bit 6
|
||||
}
|
||||
|
||||
public abstract boolean hasX64();
|
||||
|
@ -1140,6 +1140,46 @@ public class DataHelper {
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is different than InputStream.skip(), in that it
|
||||
* does repeated reads until the full amount is skipped.
|
||||
* To fix findbugs issues with skip().
|
||||
*
|
||||
* Guaranteed to skip exactly n bytes or throw an IOE.
|
||||
*
|
||||
* http://stackoverflow.com/questions/14057720/robust-skipping-of-data-in-a-java-io-inputstream-and-its-subtypes
|
||||
* http://stackoverflow.com/questions/11511093/java-inputstream-skip-return-value-near-end-of-file
|
||||
*
|
||||
* @since 0.9.9
|
||||
*/
|
||||
public static void skip(InputStream in, long n) throws IOException {
|
||||
if (n < 0)
|
||||
throw new IllegalArgumentException();
|
||||
if (n == 0)
|
||||
return;
|
||||
long read = 0;
|
||||
long nm1 = n - 1;
|
||||
if (nm1 > 0) {
|
||||
// skip all but the last byte
|
||||
do {
|
||||
long c = in.skip(nm1 - read);
|
||||
if (c < 0)
|
||||
throw new EOFException("EOF while skipping " + n + ", read only " + read);
|
||||
if (c == 0) {
|
||||
// see second SO link above
|
||||
if (in.read() == -1)
|
||||
throw new EOFException("EOF while skipping " + n + ", read only " + read);
|
||||
read++;
|
||||
} else {
|
||||
read += c;
|
||||
}
|
||||
} while (read < nm1);
|
||||
}
|
||||
// read the last byte to check for EOF
|
||||
if (in.read() == -1)
|
||||
throw new EOFException("EOF while skipping " + n + ", read only " + read);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is different than InputStream.read(target), in that it
|
||||
* does repeated reads until the full data is received.
|
||||
|
@ -53,14 +53,14 @@ abstract class SipHashInline {
|
||||
// processing 8 bytes blocks in data
|
||||
while (i < last) {
|
||||
// pack a block to long, as LE 8 bytes
|
||||
m = (long) data[i++] |
|
||||
(long) data[i++] << 8 |
|
||||
(long) data[i++] << 16 |
|
||||
(long) data[i++] << 24 |
|
||||
(long) data[i++] << 32 |
|
||||
(long) data[i++] << 40 |
|
||||
(long) data[i++] << 48 |
|
||||
(long) data[i++] << 56 ;
|
||||
m = ((((long) data[i++]) & 0xff) ) |
|
||||
((((long) data[i++]) & 0xff) << 8) |
|
||||
((((long) data[i++]) & 0xff) << 16) |
|
||||
((((long) data[i++]) & 0xff) << 24) |
|
||||
((((long) data[i++]) & 0xff) << 32) |
|
||||
((((long) data[i++]) & 0xff) << 40) |
|
||||
((((long) data[i++]) & 0xff) << 48) |
|
||||
((((long) data[i++]) & 0xff) << 56);
|
||||
// MSGROUND {
|
||||
v3 ^= m;
|
||||
|
||||
@ -132,7 +132,7 @@ abstract class SipHashInline {
|
||||
// packing the last block to long, as LE 0-7 bytes + the length in the top byte
|
||||
m = 0;
|
||||
for (i = off + len - 1; i >= last; --i) {
|
||||
m <<= 8; m |= (long) data[i];
|
||||
m <<= 8; m |= (long) (data[i] & 0xff);
|
||||
}
|
||||
m |= (long) len << 56;
|
||||
// MSGROUND {
|
||||
|
@ -69,12 +69,12 @@ public abstract class ZipFileComment {
|
||||
try {
|
||||
in = new FileInputStream(file);
|
||||
if (skip > 0)
|
||||
in.skip(skip);
|
||||
DataHelper.skip(in, skip);
|
||||
byte[] hdr = new byte[HEADER_LEN];
|
||||
DataHelper.read(in, hdr);
|
||||
if (!DataHelper.eq(hdr, magicStart))
|
||||
throw new ZipException("Not a zip file: " + file);
|
||||
in.skip(fileLen - (skip + HEADER_LEN + buffer.length));
|
||||
DataHelper.skip(in, fileLen - (skip + HEADER_LEN + buffer.length));
|
||||
DataHelper.read(in, buffer);
|
||||
return getComment(buffer);
|
||||
} finally {
|
||||
|
@ -390,6 +390,7 @@ public class BSkipSpan extends SkipSpan {
|
||||
this.prev = null;
|
||||
|
||||
BSkipSpan bss = this;
|
||||
// findbugs ok (set in load() above)
|
||||
int np = nextPage;
|
||||
while(np != 0) {
|
||||
BSkipSpan temp = bsl.spanHash.get(Integer.valueOf(np));
|
||||
|
Reference in New Issue
Block a user