Skip to content

Commit

Permalink
Replace unused out arguments with discards (#2726)
Browse files Browse the repository at this point in the history
* Replace unused out arguments with discards

* Removing unnecessary types in discarded out arguments
  • Loading branch information
benrr101 committed Jul 29, 2024
1 parent 0c45198 commit 8595644
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@ public static SafeFreeContextBufferChannelBinding QueryContextChannelBinding(SSP

public static object QueryContextAttributes(SSPIInterface secModule, SafeDeleteContext securityContext, Interop.SspiCli.ContextAttribute contextAttribute)
{
int errorCode;
return QueryContextAttributes(secModule, securityContext, contextAttribute, out errorCode);
return QueryContextAttributes(secModule, securityContext, contextAttribute, out _);
}

public static object QueryContextAttributes(SSPIInterface secModule, SafeDeleteContext securityContext, Interop.SspiCli.ContextAttribute contextAttribute, out int errorCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public static unsafe int AcquireDefaultCredential(
NetEventSource.Enter(null, package, intent);

int errorCode = -1;
long timeStamp;

outCredential = new SafeFreeCredential_SECURITY();

Expand All @@ -227,7 +226,7 @@ public static unsafe int AcquireDefaultCredential(
null,
null,
ref outCredential._handle,
out timeStamp);
out _);

#if TRACE_VERBOSE
if (NetEventSource.IsEnabled) NetEventSource.Info(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");
Expand All @@ -248,7 +247,6 @@ public static unsafe int AcquireCredentialsHandle(
out SafeFreeCredentials outCredential)
{
int errorCode = -1;
long timeStamp;

outCredential = new SafeFreeCredential_SECURITY();
errorCode = Interop.SspiCli.AcquireCredentialsHandleW(
Expand All @@ -260,7 +258,7 @@ public static unsafe int AcquireCredentialsHandle(
null,
null,
ref outCredential._handle,
out timeStamp);
out _);

if (errorCode != 0)
{
Expand All @@ -280,7 +278,6 @@ public static unsafe int AcquireCredentialsHandle(
NetEventSource.Enter(null, package, intent, authdata);

int errorCode = -1;
long timeStamp;


// If there is a certificate, wrap it into an array.
Expand All @@ -305,7 +302,7 @@ public static unsafe int AcquireCredentialsHandle(
null,
null,
ref outCredential._handle,
out timeStamp);
out _);
}
finally
{
Expand Down Expand Up @@ -632,8 +629,6 @@ private static unsafe int MustRunInitializeSecurityContext(

Interop.SspiCli.CredHandle credentialHandle = inCredentials._handle;

long timeStamp;

errorCode = Interop.SspiCli.InitializeSecurityContextW(
ref credentialHandle,
inContextPtr,
Expand All @@ -646,7 +641,7 @@ private static unsafe int MustRunInitializeSecurityContext(
ref outContext._handle,
ref outputBuffer,
ref attributes,
out timeStamp);
out _);
}
finally
{
Expand Down Expand Up @@ -919,7 +914,6 @@ private static unsafe int MustRunAcceptSecurityContext_SECURITY(
outContext.DangerousAddRef(ref ignore);

Interop.SspiCli.CredHandle credentialHandle = inCredentials._handle;
long timeStamp;

errorCode = Interop.SspiCli.AcceptSecurityContext(
ref credentialHandle,
Expand All @@ -930,7 +924,7 @@ private static unsafe int MustRunAcceptSecurityContext_SECURITY(
ref outContext._handle,
ref outputBuffer,
ref outFlags,
out timeStamp);
out _);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal bool CanBePooled
{
get
{
return (!_connectionIsDoomed && !_cannotBePooled && !_owningObject.TryGetTarget(out DbConnection _));
return (!_connectionIsDoomed && !_cannotBePooled && !_owningObject.TryGetTarget(out _));
}
}

Expand Down Expand Up @@ -102,7 +102,7 @@ internal bool IsEmancipated
// of the pool and it's owning object is no longer around to
// return it.

return (_pooledCount < 1) && !_owningObject.TryGetTarget(out DbConnection _);
return (_pooledCount < 1) && !_owningObject.TryGetTarget(out _);
}
}

Expand Down Expand Up @@ -409,7 +409,7 @@ internal void PostPop(DbConnection newOwner)
// IMPORTANT NOTE: You must have taken a lock on the object before
// you call this method to prevent race conditions with Clear and
// ReclaimEmancipatedObjects.
if (_owningObject.TryGetTarget(out DbConnection _))
if (_owningObject.TryGetTarget(out _))
{
throw ADP.InternalError(ADP.InternalErrorCode.PooledObjectHasOwner); // pooled connection already has an owner!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,13 @@ internal static unsafe uint SNISecGenClientContext(SNIHandle pConnectionObject,
fixed (byte* pin_serverUserName = &serverUserName[0])
fixed (byte* pInBuff = inBuff)
{
bool local_fDone;
return SNISecGenClientContextWrapper(
pConnectionObject,
pInBuff,
(uint)inBuff.Length,
OutBuff,
ref sendLength,
out local_fDone,
out _,
pin_serverUserName,
(uint)serverUserName.Length,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ virtual internal void DelegatedTransactionEnded()
}
pool.PutObjectFromTransactedPool(this);
}
else if (-1 == _pooledCount && !_owningObject.TryGetTarget(out DbConnection _))
else if (-1 == _pooledCount && !_owningObject.TryGetTarget(out _))
{
// When _pooledCount is -1 and the owning object no longer exists,
// it indicates a closed (or leaked), non-pooled connection so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1605,10 +1605,8 @@ private object InternalEndExecuteNonQuery(IAsyncResult asyncResult, bool isInter
{
try
{
bool dataReady;
Debug.Assert(_stateObj._syncOverAsync, "Should not attempt pends in a synchronous call");
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, null, null, _stateObj,
out dataReady);
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, null, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
throw SQL.SynchronousCallMayNotPend();
Expand Down Expand Up @@ -3680,9 +3678,8 @@ private Task RunExecuteNonQueryTds(string methodName, bool isAsync, int timeout,
}
else
{
bool dataReady;
Debug.Assert(_stateObj._syncOverAsync, "Should not attempt pends in a synchronous call");
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, null, null, _stateObj, out dataReady);
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, null, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
throw SQL.SynchronousCallMayNotPend();
Expand Down Expand Up @@ -5298,9 +5295,8 @@ private void FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, stri
{
try
{
bool dataReady;
Debug.Assert(_stateObj._syncOverAsync, "Should not attempt pends in a synchronous call");
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, ds, null, _stateObj, out dataReady);
TdsOperationStatus result = _stateObj.Parser.TryRun(RunBehavior.UntilDone, this, ds, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
throw SQL.SynchronousCallMayNotPend();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2165,8 +2165,7 @@ internal SqlInternalConnectionTds GetOpenTdsConnection(string method)

internal void OnInfoMessage(SqlInfoMessageEventArgs imevent)
{
bool notified;
OnInfoMessage(imevent, out notified);
OnInfoMessage(imevent, out _);
}

internal void OnInfoMessage(SqlInfoMessageEventArgs imevent, out bool notified)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1001,8 +1001,7 @@ private TdsOperationStatus TryCloseInternal(bool closeReader)
#endif


bool ignored;
result = parser.TryRun(RunBehavior.Clean, _command, this, null, stateObj, out ignored);
result = parser.TryRun(RunBehavior.Clean, _command, this, null, stateObj, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -3208,8 +3207,7 @@ private TdsOperationStatus TryHasMoreResults(out bool moreResults)
throw ADP.ClosedConnectionError();
}

bool ignored;
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out ignored);
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
moreResults = false;
Expand Down Expand Up @@ -3279,8 +3277,7 @@ private TdsOperationStatus TryHasMoreRows(out bool moreRows)
throw ADP.ClosedConnectionError();
}

bool ignored;
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out ignored);
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
moreRows = false;
Expand Down Expand Up @@ -4116,8 +4113,7 @@ private TdsOperationStatus TryResetBlobState()
{
if (_stateObj._longlen != 0)
{
ulong ignored;
result = _stateObj.Parser.TrySkipPlpValue(ulong.MaxValue, _stateObj, out ignored);
result = _stateObj.Parser.TrySkipPlpValue(ulong.MaxValue, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -4212,8 +4208,7 @@ internal TdsOperationStatus TrySetAltMetaDataSet(_SqlMetaDataSet metaDataSet, bo
}
if (TdsEnums.SQLORDER == b)
{
bool ignored;
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out ignored);
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, this, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand All @@ -4229,8 +4224,7 @@ internal TdsOperationStatus TrySetAltMetaDataSet(_SqlMetaDataSet metaDataSet, bo
try
{
_stateObj._accumulateInfoEvents = true;
bool ignored;
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, null, null, _stateObj, out ignored);
result = _parser.TryRun(RunBehavior.ReturnImmediately, _command, null, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -4308,9 +4302,9 @@ internal TdsOperationStatus TrySetMetaData(_SqlMetaDataSet metaData, bool moreIn

// simply rip the order token off the wire
if (b == TdsEnums.SQLORDER)
{ // same logic as SetAltMetaDataSet
bool ignored;
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out ignored);
{
// same logic as SetAltMetaDataSet
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand All @@ -4329,8 +4323,7 @@ internal TdsOperationStatus TrySetMetaData(_SqlMetaDataSet metaData, bool moreIn
try
{
_stateObj._accumulateInfoEvents = true;
bool ignored;
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out ignored);
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down
Loading

0 comments on commit 8595644

Please sign in to comment.