Thread (26 messages) flat view 26 messages, 7 authors, 2016-06-15

Re: [PATCH 2/8] strbuf: add strbuf_addv

From: Christian Couder <hidden>
Date: 2016-06-15 22:50:39

Hi,

On Thu, Feb 24, 2011 at 3:27 PM, Jeff King [off-list ref] wrote:
+void strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
+{
+       int len;
+       va_list cp;

       if (!strbuf_avail(sb))
               strbuf_grow(sb, 64);
-       va_start(ap, fmt);
-       len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
-       va_end(ap);
+       va_copy(cp, ap);
+       len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, cp);
+       va_end(cp);
       if (len < 0)
-               die("your vsnprintf is broken");
+               die("BUG: your vsnprintf is broken (returned -1)");
Minor nit: why not:

 +               die("BUG: your vsnprintf is broken (returned %d)", len);

Thanks,
Christian.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help