From 34f33a8ccb1ce0f522ea14edde8ceb976997855f Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Sat, 17 Jun 2017 21:32:10 +0700 Subject: [PATCH] Remove some dead argument checks for unsigned primitives for less than zero (#12349) * Remove dead comparisons of unsigned primitive less than zero * Delete bad assertition that is consistently hit using the Debug coreclr using the tests --- src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs index aba25e9..73a3721 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs @@ -98,8 +98,6 @@ namespace System.Runtime.InteropServices [CLSCompliant(false)] public void Initialize(ulong numBytes) { - if (numBytes < 0) - throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_NeedNonNegNum); if (IntPtr.Size == 4 && numBytes > UInt32.MaxValue) throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_AddressSpace); Contract.EndContractBlock(); @@ -117,11 +115,6 @@ namespace System.Runtime.InteropServices [CLSCompliant(false)] public void Initialize(uint numElements, uint sizeOfEachElement) { - if (numElements < 0) - throw new ArgumentOutOfRangeException(nameof(numElements), SR.ArgumentOutOfRange_NeedNonNegNum); - if (sizeOfEachElement < 0) - throw new ArgumentOutOfRangeException(nameof(sizeOfEachElement), SR.ArgumentOutOfRange_NeedNonNegNum); - if (IntPtr.Size == 4 && numElements * sizeOfEachElement > UInt32.MaxValue) throw new ArgumentOutOfRangeException("numBytes", SR.ArgumentOutOfRange_AddressSpace); Contract.EndContractBlock(); @@ -377,7 +370,6 @@ namespace System.Runtime.InteropServices private static InvalidOperationException NotInitialized() { - Debug.Assert(false, "Uninitialized SafeBuffer! Someone needs to call Initialize before using this instance!"); return new InvalidOperationException(SR.InvalidOperation_MustCallInitialize); } -- 2.7.4