On Sun, May 18, 2014 at 7:58 PM, Richard Heck <rgh...@lyx.org> wrote:
> On 05/18/2014 07:22 PM, Scott Kostyshak wrote:
>>
>> Is this OK? Note that converting the left hand side to an unsigned int
>> would work also, because it was checked just above that nRead is >=0.
>> But I figure converting the signed to unsigned is better in general as
>> long as the numbers are not expected to be large.
>
>
> I would guess the safest thing would be to convert nRead to unsigned, since
> (a) we know it
> is positive and (b) there's no possible danger of a misconversion, as there
> is in the other case.

Yeah that makes sense too. I was more worried about the 'if' block
being moved above the if block above it, in which case we would no
longer know that nRead is positive. And since the size of 'buf' is
hardcoded to 1024, it seems likely not to go past 2^31-1.

> But maybe someone who knows what they're talking about should chime in.

I would also be interested in more opinions.

Scott

Reply via email to