Remove some dead argument checks for unsigned primitives for less than zero (dotnet...
authorHugh Bellamy <hughbellars@gmail.com>
Sat, 17 Jun 2017 14:32:10 +0000 (21:32 +0700)
committerDan Moseley <danmose@microsoft.com>
Sat, 17 Jun 2017 14:32:10 +0000 (07:32 -0700)
* Remove dead comparisons of unsigned primitive less than zero

* Delete bad assertition that is consistently hit using the Debug coreclr using the tests

Commit migrated from https://github.com/dotnet/coreclr/commit/34f33a8ccb1ce0f522ea14edde8ceb976997855f

src/coreclr/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs

index aba25e9..73a3721 100644 (file)
@@ -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);
         }