Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace unused out arguments with discards #2726

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 int _);
benrr101 marked this conversation as resolved.
Show resolved Hide resolved
benrr101 marked this conversation as resolved.
Show resolved Hide resolved
}

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 long _);

#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 long _);

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 long _);
}
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 long _);
}
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 long _);
}
finally
{
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 bool _,
pin_serverUserName,
(uint)serverUserName.Length,
null,
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 bool _);
}

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 bool _);
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 bool _);
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 bool _);
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 ulong _);
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 bool _);
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 bool _);
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 bool _);
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 bool _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4141,8 +4141,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
returnValue = null;
SqlReturnValue rec = new SqlReturnValue();
rec.length = length; // In 2005 this length is -1
ushort parameterIndex;
TdsOperationStatus result = stateObj.TryReadUInt16(out parameterIndex);
TdsOperationStatus result = stateObj.TryReadUInt16(out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand All @@ -4164,9 +4163,8 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
}
}

// read status and ignore
byte ignored;
result = stateObj.TryReadByte(out ignored);
// read status
result = stateObj.TryReadByte(out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -4697,8 +4695,7 @@ internal void DrainData(TdsParserStateObject stateObj)
{
if (stateObj._longlen != 0)
{
ulong ignored;
if (TrySkipPlpValue(ulong.MaxValue, stateObj, out ignored) != TdsOperationStatus.Done)
if (TrySkipPlpValue(ulong.MaxValue, stateObj, out _) != TdsOperationStatus.Done)
{
throw SQL.SynchronousCallMayNotPend();
}
Expand Down Expand Up @@ -4782,15 +4779,14 @@ internal TdsOperationStatus TryProcessAltMetaData(int cColumns, TdsParserStateOb
{
// internal meta data class
_SqlMetaData col = altMetaDataSet[i];

byte op;
result = stateObj.TryReadByte(out op);

result = stateObj.TryReadByte(out _);
if (result != TdsOperationStatus.Done)
{
return result;
}
ushort operand;
result = stateObj.TryReadUInt16(out operand);

result = stateObj.TryReadUInt16(out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -5470,9 +5466,8 @@ private TdsOperationStatus TryProcessColInfo(_SqlMetaDataSet columns, SqlDataRea
for (int i = 0; i < columns.Length; i++)
{
_SqlMetaData col = columns[i];

byte ignored;
TdsOperationStatus result = stateObj.TryReadByte(out ignored);

TdsOperationStatus result = stateObj.TryReadByte(out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -5866,8 +5861,7 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
TdsOperationStatus result;
if (md.metaType.IsPlp)
{
ulong ignored;
result = TrySkipPlpValue(ulong.MaxValue, stateObj, out ignored);
result = TrySkipPlpValue(ulong.MaxValue, stateObj, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -6356,8 +6350,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md,
{
// If we are given -1 for length, then we read the entire value,
// otherwise only the requested amount, usually first chunk.
int ignored;
result = stateObj.TryReadPlpBytes(ref b, 0, length, out ignored);
result = stateObj.TryReadPlpBytes(ref b, 0, length, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -12782,8 +12775,7 @@ internal TdsOperationStatus TryReadPlpUnicodeChars(ref char[] buff, int offst, i
TdsOperationStatus result;
if (stateObj._longlenleft == 0)
{
ulong ignored;
result = stateObj.TryReadPlpLength(false, out ignored);
result = stateObj.TryReadPlpLength(false, out _);
if (result != TdsOperationStatus.Done)
{
totalCharsRead = 0;
Expand Down Expand Up @@ -12846,8 +12838,7 @@ internal TdsOperationStatus TryReadPlpUnicodeChars(ref char[] buff, int offst, i
return result;
}
stateObj._longlenleft--;
ulong ignored;
result = stateObj.TryReadPlpLength(false, out ignored);
result = stateObj.TryReadPlpLength(false, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand All @@ -12868,9 +12859,9 @@ internal TdsOperationStatus TryReadPlpUnicodeChars(ref char[] buff, int offst, i
totalCharsRead++;
}
if (stateObj._longlenleft == 0)
{ // Read the next chunk or cleanup state if hit the end
ulong ignored;
result = stateObj.TryReadPlpLength(false, out ignored);
{
// Read the next chunk or cleanup state if hit the end
result = stateObj.TryReadPlpLength(false, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -12977,9 +12968,7 @@ internal TdsOperationStatus TrySkipPlpValue(ulong cb, TdsParserStateObject state

if (stateObj._longlenleft == 0)
{
ulong ignored;

result = stateObj.TryReadPlpLength(false, out ignored);
result = stateObj.TryReadPlpLength(false, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand All @@ -13005,8 +12994,7 @@ internal TdsOperationStatus TrySkipPlpValue(ulong cb, TdsParserStateObject state

if (stateObj._longlenleft == 0)
{
ulong ignored;
result = stateObj.TryReadPlpLength(false, out ignored);
result = stateObj.TryReadPlpLength(false, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,8 @@ internal void SendAttention(bool mustTakeWriteLock = false, bool asyncClose = fa
return;
}

uint sniError;
_parser._asyncWrite = false; // stop async write
SNIWritePacket(attnPacket, out sniError, canAccumulate: false, callerHasConnectionLock: false, asyncClose);
SNIWritePacket(attnPacket, out uint _, canAccumulate: false, callerHasConnectionLock: false, asyncClose);
SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObject.SendAttention | Info | State Object Id {0}, Sent Attention.", _objectID);
}
finally
Expand Down
Loading
Loading