CNFS offset problems
bill davidsen
davidsen at tmr.com
Tue Jan 21 20:08:59 UTC 2003
In article <ylsmvmwbqg.fsf at windlord.stanford.edu>,
Russ Allbery <rra at stanford.edu> wrote:
|
| bill davidsen <davidsen at tmr.com> writes:
|
| > I guess the real question which comes to my mind is why the article
| > length is unsigned in the first place.
|
| I changed that for 2.4 intentionally, because a negative article length
| doesn't make any sense and because it might conceivably matter at some
| point if people try to deal with really large articles. size_t is really
| the right data type. I wasn't particularly comfortable with just using an
| int (and in general, there are a lot of places where INN uses an int that
| should be a size_t).
If we write this as:
article.len > cnfs->length - cnfs->free - CNFS_BLOCKSIZE - 1
the RHS can go negative, but if we write it as
(article.len + CNFS_BLOCKSIZE + 1) > (cnfs->length - cnfs->free)
I think both side have to be positive and will happily compare. No
comments about extra parens, people have to read code as well as
compilers.
--
bill davidsen <davidsen at tmr.com>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
More information about the inn-workers
mailing list