[Lldb-commits] [PATCH] Implement snprintf for MSVC with correct return value.
chaorenl at google.com
Wed May 27 09:24:39 PDT 2015
> So as far as I can tell the value of `errno` is undefined in the case that
> `buffer`, `format`, and `count` are all valid, but `count` is just not big
> enough (which is really the case we're trying to handle anyway).
Yeah, errno should be 0 only in the case that count is not big enough,
which is exactly what I'm checking for. (It's the caller's responsibility
to clear errno before calling snprintf). Otherwise, there's an error, and
it should be returned as is, and the fprintf wouldn't be necessary.
On Wed, May 27, 2015 at 9:19 AM, Zachary Turner <zturner at google.com> wrote:
> Yea, I saw that, but it only says that it sets `errno` in the case that
> `buffer==nullptr` or `count==0` (not sure why it says `count<=0` since
> `count` is an unsigned type). So as far as I can tell the value of `errno`
> is undefined in the case that `buffer`, `format`, and `count` are all
> valid, but `count` is just not big enough (which is really the case we're
> trying to handle anyway).
> Even in the case the MSDN doc talks about, you either won't return from
> the function at all (i.e. it will abort) or it will return `-1`. So I
> think it's best to remove the `errno` check. Otherwise lgtm.
> EMAIL PREFERENCES
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lldb-commits