[bind10-dev] trivial bug in src/lib/util/io/fd.cc

Danny Mayer mayer at gis.net
Mon Oct 17 03:19:20 UTC 2011


On 10/16/2011 12:40 PM, Francis Dupont wrote:
> In:
> 
>     size_t rest(length);
>     // Just keep writing until all is written                                   
>     while (rest) {
>         ssize_t written(write(fd, buffer, rest));
>         if (rest == -1) {
>             ^^^^ should be written
> 
> BTW the same bug is in the read, rest in == -1 must be replaced
> by amount
> 

Frankly if rest is a positive integer the line

   while (rest)

should be written as

   while (rest > 0)

Clarity is much more important. Write what your intent is and not what a
computer/compiler might interpret it as.

Danny
> Regards
> 
> Francis Dupont <fdupont at isc.org>
> _______________________________________________
> bind10-dev mailing list
> bind10-dev at lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind10-dev
> 




More information about the bind10-dev mailing list