mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-23 03:39:35 -10:00
Remove unnecessary empty try { } blocks (dotnet/corefx#39664)
Unnecessary in .NET Core code. I didn't modify additional instances in libraries that target netstandard/netfx. Commit migrated from https://github.com/dotnet/corefx/commit/ca795a928d210c78c6bbd3fa10eb35f4c093a5a4
This commit is contained in:
1 parent
1efab71f21
commit
c58629fe45
3 files changed
+45
-71
No files matched your search
+15
-22
@@ -32,30 +32,23 @@ namespace System.IO
|
||||
return;
|
||||
}
|
||||
|
||||
// Open an inotify file descriptor. Ideally this would be a constrained execution region, but we don't have access to
|
||||
// PrepareConstrainedRegions. We still use a finally block to house the code that opens the handle and stores it in
|
||||
// hopes of making it as non-interruptible as possible. Ideally the SafeFileHandle would be allocated before the block,
|
||||
// but SetHandle is protected and SafeFileHandle is sealed, so we're stuck doing the allocation here.
|
||||
SafeFileHandle handle;
|
||||
try { } finally
|
||||
// Open an inotify file descriptor.
|
||||
SafeFileHandle handle = Interop.Sys.INotifyInit();
|
||||
if (handle.IsInvalid)
|
||||
{
|
||||
handle = Interop.Sys.INotifyInit();
|
||||
if (handle.IsInvalid)
|
||||
Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo();
|
||||
switch (error.Error)
|
||||
{
|
||||
Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo();
|
||||
switch (error.Error)
|
||||
{
|
||||
case Interop.Error.EMFILE:
|
||||
string maxValue = ReadMaxUserLimit(MaxUserInstancesPath);
|
||||
string message = !string.IsNullOrEmpty(maxValue) ?
|
||||
SR.Format(SR.IOException_INotifyInstanceUserLimitExceeded_Value, maxValue) :
|
||||
SR.IOException_INotifyInstanceUserLimitExceeded;
|
||||
throw new IOException(message, error.RawErrno);
|
||||
case Interop.Error.ENFILE:
|
||||
throw new IOException(SR.IOException_INotifyInstanceSystemLimitExceeded, error.RawErrno);
|
||||
default:
|
||||
throw Interop.GetExceptionForIoErrno(error);
|
||||
}
|
||||
case Interop.Error.EMFILE:
|
||||
string maxValue = ReadMaxUserLimit(MaxUserInstancesPath);
|
||||
string message = !string.IsNullOrEmpty(maxValue) ?
|
||||
SR.Format(SR.IOException_INotifyInstanceUserLimitExceeded_Value, maxValue) :
|
||||
SR.IOException_INotifyInstanceUserLimitExceeded;
|
||||
throw new IOException(message, error.RawErrno);
|
||||
case Interop.Error.ENFILE:
|
||||
throw new IOException(SR.IOException_INotifyInstanceSystemLimitExceeded, error.RawErrno);
|
||||
default:
|
||||
throw Interop.GetExceptionForIoErrno(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user