[Mono-dev] mcs warnings

Greg Young gregoryyoung1 at gmail.com
Fri Mar 21 12:33:44 UTC 2014


I was looking through some of the mcs warnings on mono build today and some
seem to be off from looking at the code

System.Collections.Concurrent/BlockingCollection.cs(387,4): warning CS0162:
Unreachable code detected
System.Collections.Concurrent/BlockingCollection.cs(375,9): warning CS0219:
The variable `index' is assigned but its value is never used
System.Collections.Concurrent/BlockingCollection.cs(412,4): warning CS0162:
Unreachable code detected
System.Collections.Concurrent/BlockingCollection.cs(396,9): warning CS0219:
The variable `index' is assigned but its value is never used
System.Net/WebConnectionStream.cs(695,11): warning CS0219: The variable
`bytes' is assigned but its value is never used
System.Diagnostics/TraceImpl.cs(44,15): warning CS0649: Field
`System.Diagnostics.TraceImplSettings.AutoFlush' is never assigned to, and
will always have its default value `false'

Take the index is assigned but value never used. Here is related code from
that area

public static int TakeFromAny (BlockingCollection<T>[] collections, out T
item)
{
item = default (T);
CheckArray (collections);
int index = 0;
foreach (var coll in collections) {
try {
item = coll.Take ();
return index;
} catch {}
index++;
}
return -1;
}

public static int TakeFromAny (BlockingCollection<T>[] collections, out T
item, CancellationToken cancellationToken)
{
item = default (T);
CheckArray (collections);
int index = 0;
foreach (var coll in collections) {
try {
item = coll.Take (cancellationToken);
return index;
} catch {}
index++;
}
return -1;
}

public static int TryTakeFromAny (BlockingCollection<T>[] collections, out
T item)
{
item = default (T);

CheckArray (collections);
int index = 0;
foreach (var coll in collections) {
if (coll.TryTake (out item))
return index;
index++;
}
return -1;
}

Also should the line number be pointing to the actual line in the source?
In this case it was pointing at a }catch{} (on the first one). I don't see
how index is not being used there

-- 
Le doute n'est pas une condition agréable, mais la certitude est absurde.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20140321/74c78e97/attachment.html>


More information about the Mono-devel-list mailing list