Content originally posted in LPCWare by Pacman on Mon Apr 21 14:37:07 MST 2014
That code looks absolutely wonderful. :)
length is a const int *, which means: it's not marked volatile, thus you can assume that all the *length will always return the same value.
So... Let's say length points to a value of 10.
bytesToRead = 10.
bytesToRead = (10 < 10) ? 10 : 10;
BytesRead = 10;
In other words, the above can be simplified to:
bytesRead = *length;
... I've also seen code (somewhere else) like this:
if(a == 10)
{
a = 10;
}
...Anyway, the code you've mentioned is clearly not doing what the programmer intended it to do.