Date: Sun, 25 May 2003 00:13:03 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 31840 for review Message-ID: <200305250713.h4P7D3nu046703@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=31840 Change 31840 by peter@peter_hammer on 2003/05/25 00:12:18 Fix subr_sbuf.c so that it doesn't trash the varargs state. What it was doing was utterly illegal. You have to use va_copy() to save the state so you can use it again. Affected files ... .. //depot/projects/hammer/sys/geom/geom_kern.c#12 edit .. //depot/projects/hammer/sys/kern/subr_sbuf.c#5 edit Differences ... ==== //depot/projects/hammer/sys/geom/geom_kern.c#12 (text+ko) ==== @@ -164,7 +164,6 @@ SHUTDOWN_PRI_FIRST); } -#ifndef __amd64__ /* provokes compiler bug in geom_dump.c */ static int sysctl_kern_geom_conftxt(SYSCTL_HANDLER_ARGS) { @@ -206,11 +205,9 @@ sbuf_delete(sb); return error; } -#endif SYSCTL_NODE(_kern, OID_AUTO, geom, CTLFLAG_RW, 0, "GEOMetry management"); -#ifndef __amd64__ /* provokes compiler bug in geom_dump.c */ SYSCTL_PROC(_kern_geom, OID_AUTO, confxml, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, sysctl_kern_geom_confxml, "", "Dump the GEOM config in XML"); @@ -222,7 +219,6 @@ SYSCTL_PROC(_kern_geom, OID_AUTO, conftxt, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, sysctl_kern_geom_conftxt, "", "Dump the GEOM config in txt"); -#endif SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RW, &g_debugflags, 0, ""); ==== //depot/projects/hammer/sys/kern/subr_sbuf.c#5 (text+ko) ==== @@ -399,6 +399,7 @@ int sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap) { + va_list ap_copy; int len; assert_sbuf_integrity(s); @@ -411,8 +412,10 @@ return (-1); do { + va_copy(ap_copy, ap); len = vsnprintf(&s->s_buf[s->s_len], SBUF_FREESPACE(s) + 1, - fmt, ap); + fmt, ap_copy); + va_end(ap_copy); } while (len > SBUF_FREESPACE(s) && sbuf_extend(s, len - SBUF_FREESPACE(s)) == 0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305250713.h4P7D3nu046703>
