diff --git a/DiscImageChef.Checksums/CRC16Context.cs b/DiscImageChef.Checksums/CRC16Context.cs
index bbac567d..e5b007d6 100644
--- a/DiscImageChef.Checksums/CRC16Context.cs
+++ b/DiscImageChef.Checksums/CRC16Context.cs
@@ -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);
diff --git a/DiscImageChef.Checksums/CRC32Context.cs b/DiscImageChef.Checksums/CRC32Context.cs
index 485880f0..f6c88de2 100644
--- a/DiscImageChef.Checksums/CRC32Context.cs
+++ b/DiscImageChef.Checksums/CRC32Context.cs
@@ -73,7 +73,7 @@ namespace DiscImageChef.Checksums
/// Length of buffer to hash.
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)];
}
///
@@ -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;
diff --git a/DiscImageChef.Checksums/CRC64Context.cs b/DiscImageChef.Checksums/CRC64Context.cs
index c15ad5eb..c47a9825 100644
--- a/DiscImageChef.Checksums/CRC64Context.cs
+++ b/DiscImageChef.Checksums/CRC64Context.cs
@@ -72,7 +72,7 @@ namespace DiscImageChef.Checksums
/// Length of buffer to hash.
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)];
}
///
@@ -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;
diff --git a/DiscImageChef.Core/Devices/Report/ATA.cs b/DiscImageChef.Core/Devices/Report/ATA.cs
index 21b30f56..a1c11414 100644
--- a/DiscImageChef.Core/Devices/Report/ATA.cs
+++ b/DiscImageChef.Core/Devices/Report/ATA.cs
@@ -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;
diff --git a/DiscImageChef.Decoders/Floppy/Apple2.cs b/DiscImageChef.Decoders/Floppy/Apple2.cs
index 2ddda2d0..554f78cc 100644
--- a/DiscImageChef.Decoders/Floppy/Apple2.cs
+++ b/DiscImageChef.Decoders/Floppy/Apple2.cs
@@ -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);
}
}
diff --git a/DiscImageChef.DiscImages/Partimage.cs b/DiscImageChef.DiscImages/Partimage.cs
index 4b5b069b..2430e1d7 100644
--- a/DiscImageChef.DiscImages/Partimage.cs
+++ b/DiscImageChef.DiscImages/Partimage.cs
@@ -508,13 +508,13 @@ namespace DiscImageChef.DiscImages
DateTime start = DateTime.Now;
extents = new ExtentsULong();
extentsOff = new Dictionary();
- 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;
diff --git a/DiscImageChef.Helpers/Swapping.cs b/DiscImageChef.Helpers/Swapping.cs
index 4cbccea6..75bec257 100644
--- a/DiscImageChef.Helpers/Swapping.cs
+++ b/DiscImageChef.Helpers/Swapping.cs
@@ -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;
}
diff --git a/DiscImageChef.Tests.Devices/DecodeATARegisters.cs b/DiscImageChef.Tests.Devices/DecodeATARegisters.cs
index 1dac4df4..31a3cb9e 100644
--- a/DiscImageChef.Tests.Devices/DecodeATARegisters.cs
+++ b/DiscImageChef.Tests.Devices/DecodeATARegisters.cs
@@ -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();