Dimitrios Apostolou <jimis@gmx.net> writes:
> + /* Dump buffer if full */
> + if (nonecs->bufdata >= nonecs->buflen)
> Shouldn't this be equality check instead:
> if (nonecs->bufdata == nonecs->buflen)
Old defensive-programming habit. The invariant we want to establish
is that there's some space available, ie
nonecs->bufdata < nonecs->buflen
and if we just test for equality then we haven't proven that.
Agreed that bufdata shouldn't ever be greater than buflen, but if
it somehow is, an equality test here would contribute to making
things worse (writing ever further past the buffer) not better.
> And possibly also assert(nonecs->bufdata <= nonecs->buflen) ?
Maybe, but that code is simple enough that I didn't see a big
need for an assertion check.
regards, tom lane