From d2ecd0c777632d43f8de72e952ae151d2f6d5fff Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 18 Mar 2023 13:19:06 +0000 Subject: [PATCH] Fix RCS1216 --- .editorconfig | 3 +++ .../FileFormats/BlowfishKeyProvider.cs | 27 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.editorconfig b/.editorconfig index 33ffd2c055..5a446e4c9d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1094,6 +1094,9 @@ dotnet_diagnostic.RCS1214.severity = warning # Expression is always equal to 'true'. dotnet_diagnostic.RCS1215.severity = warning +# Unnecessary unsafe context. +dotnet_diagnostic.RCS1216.severity = warning + # Use pattern matching instead of combination of 'is' operator and cast operator. dotnet_diagnostic.RCS1220.severity = warning diff --git a/OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs b/OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs index 2d00dd1bc3..a683e189ed 100644 --- a/OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs +++ b/OpenRA.Mods.Cnc/FileFormats/BlowfishKeyProvider.cs @@ -284,24 +284,21 @@ namespace OpenRA.Mods.Cnc.FileFormats static unsafe void MulBignumWord(ushort* pn1, uint[] n2, uint mul, uint len) { uint i, tmp; - unsafe + fixed (uint* tempPn2 = &n2[0]) { - fixed (uint* tempPn2 = &n2[0]) + var pn2 = (ushort*)tempPn2; + + tmp = 0; + for (i = 0; i < len; i++) { - var pn2 = (ushort*)tempPn2; - - tmp = 0; - for (i = 0; i < len; i++) - { - tmp = mul * *pn2 + *pn1 + tmp; - *pn1 = (ushort)tmp; - pn1++; - pn2++; - tmp >>= 16; - } - - *pn1 += (ushort)tmp; + tmp = mul * *pn2 + *pn1 + tmp; + *pn1 = (ushort)tmp; + pn1++; + pn2++; + tmp >>= 16; } + + *pn1 += (ushort)tmp; } }