Commit 8fabd4aa authored by Federico G. Schwindt's avatar Federico G. Schwindt Committed by Lasse Karstensen

Add a VSL variant that takes uses stdarg(3)

parent b9a817ae
......@@ -957,6 +957,7 @@ void *VSM_Alloc(unsigned size, const char *class, const char *type,
const char *ident);
void VSM_Free(void *ptr);
#ifdef VSL_ENDMARKER
void VSLv(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, va_list va);
void VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...)
__v_printflike(3, 4);
void VSLbv(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, va_list va);
......
......@@ -207,9 +207,8 @@ vslr(enum VSL_tag_e tag, uint32_t vxid, const char *b, unsigned len)
*/
void
VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...)
VSLv(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, va_list ap)
{
va_list ap;
unsigned n, mlen = cache_param->vsl_reclen;
char buf[mlen];
......@@ -217,18 +216,26 @@ VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...)
if (vsl_tag_is_masked(tag))
return;
if (strchr(fmt, '%') == NULL) {
vslr(tag, vxid, fmt, strlen(fmt) + 1);
} else {
va_start(ap, fmt);
n = vsnprintf(buf, mlen, fmt, ap);
va_end(ap);
if (n > mlen - 1)
n = mlen - 1;
buf[n++] = '\0'; /* NUL-terminated */
vslr(tag, vxid, buf, n);
}
}
void
VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
VSLv(tag, vxid, fmt, ap);
va_end(ap);
}
/*--------------------------------------------------------------------*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment