Skip to content

Commit

Permalink
Add checked for CA2020
Browse files Browse the repository at this point in the history
  • Loading branch information
slozier committed Mar 20, 2024
1 parent e72fc47 commit 2bd2dae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_overlapped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class PythonOverlapped {
private static extern IntPtr _CreateIoCompletionPort(IntPtr FileHandle, IntPtr ExistingCompletionPort, UIntPtr CompletionKey, uint NumberOfConcurrentThreads);

public static BigInteger CreateIoCompletionPort(BigInteger handle, BigInteger port, BigInteger key, int concurrency) {
var res = _CreateIoCompletionPort((IntPtr)(long)handle, (IntPtr)(long)port, (UIntPtr)(ulong)key, (uint)concurrency);
var res = _CreateIoCompletionPort(checked((IntPtr)(long)handle), checked((IntPtr)(long)port), checked((UIntPtr)(ulong)key), (uint)concurrency);
if (res == IntPtr.Zero) {
throw PythonNT.GetLastWin32Error();
}
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ public string __repr__(CodeContext context) {
/// </summary>
internal static Socket? HandleToSocket(Int64 handle) {
lock (_handleToSocket) {
if (_handleToSocket.TryGetValue((IntPtr)handle, out WeakReference? weakref)) {
if (_handleToSocket.TryGetValue(checked((IntPtr)handle), out WeakReference? weakref)) {
return weakref.Target as Socket;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_winapi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class PythonWinApi {
throw new NotImplementedException();
}
else {
var result = ConnectNamedPipe((IntPtr)(long)handle, IntPtr.Zero);
var result = ConnectNamedPipe(checked((IntPtr)(long)handle), IntPtr.Zero);

if (!result) throw PythonNT.GetLastWin32Error();

Expand Down

0 comments on commit 2bd2dae

Please sign in to comment.