Date: Sat, 14 Mar 2015 23:30:04 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280013 - in head/sys/mips: nlm rmi Message-ID: <201503142330.t2ENU4TM054680@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Sat Mar 14 23:30:03 2015 New Revision: 280013 URL: https://svnweb.freebsd.org/changeset/base/280013 Log: Use sbuf_printf() for sysctl strings instead of static buffers and snprintf. Modified: head/sys/mips/nlm/cms.c head/sys/mips/rmi/fmn.c Modified: head/sys/mips/nlm/cms.c ============================================================================== --- head/sys/mips/nlm/cms.c Sat Mar 14 23:16:12 2015 (r280012) +++ head/sys/mips/nlm/cms.c Sat Mar 14 23:30:03 2015 (r280013) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/proc.h> #include <sys/limits.h> #include <sys/bus.h> +#include <sys/sbuf.h> #include <sys/ktr.h> #include <sys/kernel.h> @@ -473,27 +474,22 @@ SYSINIT(start_msgring_threads, SI_SUB_SM static int sys_print_debug(SYSCTL_HANDLER_ARGS) { - int error, nb, i, fs; - static char xprintb[4096], *buf; + struct sbuf sb; + int error, i; - buf = xprintb; - fs = sizeof(xprintb); - nb = snprintf(buf, fs, + sbuf_new_for_sysctl(&sb, NULL, 64, req); + sbuf_printf(&sb, "\nID vc0 vc1 vc2 vc3 loops\n"); - buf += nb; - fs -= nb; for (i = 0; i < 32; i++) { if ((xlp_hw_thread_mask & (1 << i)) == 0) continue; - nb = snprintf(buf, fs, - "%2d: %8d %8d %8d %8d %8d\n", i, + sbuf_printf(&sb, "%2d: %8d %8d %8d %8d %8d\n", i, fmn_msgcount[i][0], fmn_msgcount[i][1], fmn_msgcount[i][2], fmn_msgcount[i][3], fmn_loops[i]); - buf += nb; - fs -= nb; } - error = SYSCTL_OUT(req, xprintb, buf - xprintb); + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); } Modified: head/sys/mips/rmi/fmn.c ============================================================================== --- head/sys/mips/rmi/fmn.c Sat Mar 14 23:16:12 2015 (r280012) +++ head/sys/mips/rmi/fmn.c Sat Mar 14 23:30:03 2015 (r280013) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/proc.h> #include <sys/limits.h> #include <sys/bus.h> +#include <sys/sbuf.h> #include <sys/ktr.h> #include <sys/kernel.h> @@ -468,27 +469,22 @@ SYSINIT(start_msgring_threads, SI_SUB_SM static int sys_print_debug(SYSCTL_HANDLER_ARGS) { - int error, nb, i, fs; - static char xprintb[4096], *buf; + struct sbuf sb; + int error, i; - buf = xprintb; - fs = sizeof(xprintb); - nb = snprintf(buf, fs, + sbuf_new_for_sysctl(&sb, NULL, 64, req); + sbuf_printf(&sb, "\nID INTR ER WU-SLP WU-ERR MSGS\n"); - buf += nb; - fs -= nb; for (i = 0; i < 32; i++) { if ((xlr_hw_thread_mask & (1 << i)) == 0) continue; - nb = snprintf(buf, fs, - "%2d: %8d %4d %8d %8d %8d\n", i, + sbuf_printf(&sb, "%2d: %8d %4d %8d %8d %8d\n", i, msgring_nintr[i/4], msgring_badintr[i/4], msgring_wakeup_sleep[i], msgring_wakeup_nosleep[i], msgring_nmsgs[i]); - buf += nb; - fs -= nb; } - error = SYSCTL_OUT(req, xprintb, buf - xprintb); + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503142330.t2ENU4TM054680>