mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Add parentheses to avoid non-obvious precedence.
This commit is contained in:
@@ -148,7 +148,7 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
|
||||
for(int i = 0; i < fileStream.Length; i++)
|
||||
localhashInt = (ushort)((localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ localhashInt & 0xff]);
|
||||
localhashInt = (ushort)((localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ (localhashInt & 0xff)]);
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
hash = BigEndianBitConverter.GetBytes(localhashInt);
|
||||
@@ -200,7 +200,7 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
|
||||
for(int i = 0; i < len; i++)
|
||||
localhashInt = (ushort)((localhashInt >> 8) ^ localTable[data[i] ^ localhashInt & 0xff]);
|
||||
localhashInt = (ushort)((localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)]);
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
hash = BigEndianBitConverter.GetBytes(localhashInt);
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace DiscImageChef.Checksums
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len)
|
||||
{
|
||||
for(int i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ hashInt & 0xff];
|
||||
for(int i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xff)];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,7 +148,7 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
|
||||
for(int i = 0; i < fileStream.Length; i++)
|
||||
localhashInt = (localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ localhashInt & 0xff];
|
||||
localhashInt = (localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ (localhashInt & 0xff)];
|
||||
|
||||
localhashInt ^= CRC32_SEED;
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
@@ -200,7 +200,7 @@ namespace DiscImageChef.Checksums
|
||||
localTable[i] = entry;
|
||||
}
|
||||
|
||||
for(int i = 0; i < len; i++) localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ localhashInt & 0xff];
|
||||
for(int i = 0; i < len; i++) localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)];
|
||||
|
||||
localhashInt ^= CRC32_SEED;
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace DiscImageChef.Checksums
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
public void Update(byte[] data, uint len)
|
||||
{
|
||||
for(int i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ hashInt & 0xff];
|
||||
for(int i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xff)];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -147,7 +147,7 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
|
||||
for(int i = 0; i < fileStream.Length; i++)
|
||||
localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ localhashInt & 0xffL];
|
||||
localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ (localhashInt & 0xffL)];
|
||||
|
||||
localhashInt ^= CRC64_SEED;
|
||||
BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian;
|
||||
@@ -199,7 +199,7 @@ namespace DiscImageChef.Checksums
|
||||
localTable[i] = entry;
|
||||
}
|
||||
|
||||
for(int i = 0; i < len; i++) localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ localhashInt & 0xff];
|
||||
for(int i = 0; i < len; i++) localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)];
|
||||
|
||||
localhashInt ^= CRC64_SEED;
|
||||
BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian;
|
||||
|
||||
@@ -608,7 +608,7 @@ namespace DiscImageChef.Core.Devices.Report
|
||||
{
|
||||
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
physicalsectorsize =
|
||||
(uint)(logicalsectorsize * (1 << ataId.PhysLogSectorSize & 0xF));
|
||||
(uint)(logicalsectorsize * ((1 << ataId.PhysLogSectorSize) & 0xF));
|
||||
#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
}
|
||||
else physicalsectorsize = logicalsectorsize;
|
||||
|
||||
@@ -233,8 +233,8 @@ namespace DiscImageChef.Decoders.Floppy
|
||||
byte b1 = buffer[51 * 3 - i];
|
||||
byte b2 = buffer[51 * 2 - i];
|
||||
byte b3 = buffer[51 - i];
|
||||
byte b4 = (byte)(((b1 & 2) << 1 | (b2 & 2) | (b3 & 2) >> 1) & 0xFF);
|
||||
byte b5 = (byte)(((b1 & 1) << 2 | (b2 & 1) << 1 | (b3 & 1)) & 0xFF);
|
||||
byte b4 = (byte)((((b1 & 2) << 1) | (b2 & 2) | ((b3 & 2) >> 1)) & 0xFF);
|
||||
byte b5 = (byte)((((b1 & 1) << 2) | ((b2 & 1) << 1) | (b3 & 1)) & 0xFF);
|
||||
output[250 - 5 * i] = (byte)(((buffer[i + 51 * 3 + 1] << 3) | ((b1 >> 2) & 0x7)) & 0xFF);
|
||||
output[251 - 5 * i] = (byte)(((buffer[i + 51 * 4 + 1] << 3) | ((b2 >> 2) & 0x7)) & 0xFF);
|
||||
output[252 - 5 * i] = (byte)(((buffer[i + 51 * 5 + 1] << 3) | ((b3 >> 2) & 0x7)) & 0xFF);
|
||||
@@ -270,18 +270,18 @@ namespace DiscImageChef.Decoders.Floppy
|
||||
|
||||
if(i < 86)
|
||||
{
|
||||
output[i] |= (byte)((buffer[i] & 1) << 1 & 0xFF);
|
||||
output[i] |= (byte)((buffer[i] & 2) >> 1 & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i] & 1) << 1) & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i] & 2) >> 1) & 0xFF);
|
||||
}
|
||||
else if(i < 86 * 2)
|
||||
{
|
||||
output[i] |= (byte)((buffer[i - 86] & 4) >> 1 & 0xFF);
|
||||
output[i] |= (byte)((buffer[i - 86] & 8) >> 3 & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i - 86] & 4) >> 1) & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i - 86] & 8) >> 3) & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
output[i] |= (byte)((buffer[i - 86 * 2] & 0x10) >> 3 & 0xFF);
|
||||
output[i] |= (byte)((buffer[i - 86 * 2] & 0x20) >> 5 & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i - 86 * 2] & 0x10) >> 3) & 0xFF);
|
||||
output[i] |= (byte)(((buffer[i - 86 * 2] & 0x20) >> 5) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -508,13 +508,13 @@ namespace DiscImageChef.DiscImages
|
||||
DateTime start = DateTime.Now;
|
||||
extents = new ExtentsULong();
|
||||
extentsOff = new Dictionary<ulong, ulong>();
|
||||
bool current = (bitmap[0] & 1 << (int)(0 % 8)) != 0;
|
||||
bool current = (bitmap[0] & (1 << (int)(0 % 8))) != 0;
|
||||
ulong blockOff = 0;
|
||||
ulong extentStart = 0;
|
||||
|
||||
for(ulong i = 1; i <= localHeader.qwBlocksCount; i++)
|
||||
{
|
||||
bool next = (bitmap[i / 8] & 1 << (int)(i % 8)) != 0;
|
||||
bool next = (bitmap[i / 8] & (1 << (int)(i % 8))) != 0;
|
||||
|
||||
// Flux
|
||||
if(next != current)
|
||||
@@ -572,7 +572,7 @@ namespace DiscImageChef.DiscImages
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
|
||||
string.Format("Sector address {0} not found", sectorAddress));
|
||||
|
||||
if((bitmap[sectorAddress / 8] & 1 << (int)(sectorAddress % 8)) == 0) return new byte[ImageInfo.SectorSize];
|
||||
if((bitmap[sectorAddress / 8] & (1 << (int)(sectorAddress % 8))) == 0) return new byte[ImageInfo.SectorSize];
|
||||
|
||||
byte[] sector;
|
||||
|
||||
@@ -618,7 +618,7 @@ namespace DiscImageChef.DiscImages
|
||||
bool allEmpty = true;
|
||||
for(uint i = 0; i < length; i++)
|
||||
{
|
||||
if((bitmap[sectorAddress / 8] & 1 << (int)(sectorAddress % 8)) != 0)
|
||||
if((bitmap[sectorAddress / 8] & (1 << (int)(sectorAddress % 8))) != 0)
|
||||
{
|
||||
allEmpty = false;
|
||||
break;
|
||||
|
||||
@@ -105,9 +105,9 @@ namespace DiscImageChef
|
||||
|
||||
public static ulong Swap(ulong x)
|
||||
{
|
||||
x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000) >> 32;
|
||||
x = (x & 0x0000FFFF0000FFFF) << 16 | (x & 0xFFFF0000FFFF0000) >> 16;
|
||||
x = (x & 0x00FF00FF00FF00FF) << 8 | (x & 0xFF00FF00FF00FF00) >> 8;
|
||||
x = ((x & 0x00000000FFFFFFFF) << 32) | ((x & 0xFFFFFFFF00000000) >> 32);
|
||||
x = ((x & 0x0000FFFF0000FFFF) << 16) | ((x & 0xFFFF0000FFFF0000) >> 16);
|
||||
x = ((x & 0x00FF00FF00FF00FF) << 8) | ((x & 0xFF00FF00FF00FF00) >> 8);
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace DiscImageChef.Tests.Devices
|
||||
sb.AppendFormat("Status: {0}", DecodeATAStatus(registers.status)).AppendLine();
|
||||
sb.AppendFormat("Error: {0}", DecodeATAStatus(registers.error)).AppendLine();
|
||||
sb.AppendFormat("Device: {0}", (registers.deviceHead >> 4) & 0x01).AppendLine();
|
||||
sb.AppendFormat("Cylinder: {0}", registers.cylinderHigh << 8 + registers.cylinderLow).AppendLine();
|
||||
sb.AppendFormat("Cylinder: {0}", registers.cylinderHigh << (8 + registers.cylinderLow)).AppendLine();
|
||||
sb.AppendFormat("Head: {0}", registers.deviceHead & 0xF).AppendLine();
|
||||
sb.AppendFormat("Sector: {0}", registers.sector).AppendLine();
|
||||
sb.AppendFormat("Count: {0}", registers.sectorCount).AppendLine();
|
||||
|
||||
Reference in New Issue
Block a user