[Lldb-commits] [PATCH] Implement snprintf for MSVC with correct return value.

Chaoren Lin 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.
>
>
> http://reviews.llvm.org/D10048
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150527/a6e81c6b/attachment.html>


More information about the lldb-commits mailing list