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

Christos Zoulas christos at zoulas.com
Mon Oct 17 14:18:00 UTC 2011


On Oct 16, 11:19pm, mayer at gis.net (Danny Mayer) wrote:
-- Subject: Re: [bind10-dev] trivial bug in src/lib/util/io/fd.cc

| 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
| > 

I personally find the constructor syntax for primitive/integral types
confusing. Why do:

    ssize_t written(write(fd, buffer, rest));

when it is equivalent and cleaner to do:

    ssize_t written = write(fd, buffer, rest);

What's next? Are we going to start writing in the future:

    while (written())

instead of:

    while (written)

just for orthogonality if the next version of the language adds this
sparkling new feature? Which is easy to add BTW, just a few more lines
of yacc grammar.

christos



More information about the bind10-dev mailing list