Re: [reSIProcate] rutil/DataBuffer.cxx: likely signed-ness problem
thanks for pointing this out. I barely remember writing this.
I agree that the true branch always triggers. this is probably not a
problem since reallocating is certainly safe, if possibly not needed.
I have no idea why overflow would be called without actual overflow.
if someone is feeling ambitions, figure out why overflow would be
called if there is already room, and test it. it is possible that we
are wasting bits here.
replacing len >= 0 with pptr() >= pbase() will work to prevent
reallocation when there is room left, assuming these functions have no
side effects.
david
(who has written nothing but Java for the last 5 years, so caveat emptor)
On Mon, Dec 20, 2010 at 9:04 PM, Kennard White
<kennard_white@xxxxxxxxxxxx> wrote:
> Hi,
>
> Static code analysis indicates a likely problem in rutil/DataBuffer.cxx:
>
> int
> DataBuffer::overflow(int c)
> {
> // sync, but reallocate
> size_t len = pptr() - pbase();
> if (len >= 0)
> {
>
>
> Since size_t is unsigned, the if statement is always true. My guess is that
> the original author wanted len to be a signed type. But I have no idea what
> this function does. Anyone?
>
> Kennard
>
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxx
> https://list.resiprocate.org/mailman/listinfo/resiprocate-devel
>