[haiku-commits] Re: r40726 - haiku/trunk/src/kits/support

On 2011-02-28 at 03:41:08 [+0100], Jonas Sundström <jonas@xxxxxxxxxxx> wrote:
[ ... ]
> I think               bytes = bytes < 0 ? 0 : bytes;
> is more clear than    bytes = min_clamp0(bytes, bytes);

I agree.

> A positive 'bytes' is meant to be kept, and zero only assigned in case
> of a negative return due to a vsnprintf() output error.
> 
> The BString buffer is unlocked using 'bytes'. I think that in case of
> error, it's better to have it truncate, UnlockBuffer(0), than to have
> UnlockBuffer(negative) run strlen(fPrivateData) on the failed output
> of vsnprintf().

Sure.

> Is the use of min_clamp0() preferred in this case?
> File scope uniformity?

Nope, min_clamp0() is meant to compute the minimum of two different values, 
additionally clamping to 0. You only have one value here, so I wouldn't use 
min_clamp0().

cheers,
        Oliver

Other related posts: