32 bit int shifted by 48 bits in read8(RandomAccessFile) in IconExe.java
GoogleCodeExporter opened this issue · comments
Google Code Exporter commented
Bug report generated from FindBugs
32 bit int shifted by 48 bits in read8(RandomAccessFile)
In class org.eclipse.equinox.internal.p2.swt.tools.IconExe
In method read8(RandomAccessFile)
Shifted by 48 bits
Local variable named b6
At IconExe.java:[line 703]
Relevant source code:
699: int b4 = raf.readByte() & 0xFF;
700: int b5 = raf.readByte() & 0xFF;
701: int b6 = raf.readByte() & 0xFF;
702: int b7 = raf.readByte() & 0xFF;
703: return b7 << 56 | b6 << 48 | b5 << 40 | b4 << 32 | b3 << 24 | b2 << 16 | b1 << 8 | b0;
704: }
705: static void write4(RandomAccessFile raf, int value) throws IOException {
706: raf.write(value & 0xFF);
707: raf.write((value >> 8) & 0xFF);
Bug pattern explanation:
The code performs shift of a 32 bit int by a constant amount outside the range
0..31. The effect of this is to use the lower 5 bits of the integer value to
decide how much to shift by (e.g., shifting by 40 bits is the same as shifting
by 8 bits, and shifting by 32 bits is the same as shifting by zero bits). This
probably isn't want was expected, and it at least confusing.
FindBugs issue identifier (do not modify or remove):
6cc92720328a529bbd7d368584984203
Original issue reported on code.google.com by keithl
on 17 Feb 2010 at 3:01
Google Code Exporter commented
Original comment by keithl
on 17 Feb 2010 at 3:05
- Changed state: Invalid