diff options
| author | Rob Johnston <rob.johnston@joyent.com> | 2018-09-11 22:37:24 +0000 |
|---|---|---|
| committer | Dan McDonald <danmcd@joyent.com> | 2019-01-28 17:45:31 -0500 |
| commit | 1de1e652632a9912511ab1cd8c8c4628d5e5f1da (patch) | |
| tree | 754e4cf37cda54400c62cae43e635fb239733ebb | |
| parent | c184cb88c90fee3b48cddeae76fbb4f8065ce83a (diff) | |
| download | illumos-joyent-1de1e652632a9912511ab1cd8c8c4628d5e5f1da.tar.gz | |
10291 topo_dprintf should evaluate debug mask before forging ahead
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Gergő Mihály Doma <domag02@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
| -rw-r--r-- | usr/src/lib/fm/topo/libtopo/common/topo_mod.c | 6 | ||||
| -rw-r--r-- | usr/src/lib/fm/topo/libtopo/common/topo_subr.c | 11 | ||||
| -rw-r--r-- | usr/src/lib/fm/topo/libtopo/common/topo_subr.h | 3 |
3 files changed, 10 insertions, 10 deletions
diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_mod.c b/usr/src/lib/fm/topo/libtopo/common/topo_mod.c index 281ab28a28..8ff833cb86 100644 --- a/usr/src/lib/fm/topo/libtopo/common/topo_mod.c +++ b/usr/src/lib/fm/topo/libtopo/common/topo_mod.c @@ -758,14 +758,14 @@ topo_mod_clrdebug(topo_mod_t *mod) void topo_mod_dprintf(topo_mod_t *mod, const char *format, ...) { + topo_hdl_t *thp = mod->tm_hdl; va_list alist; - if (mod->tm_debug == 0) + if (mod->tm_debug == 0 || !(thp->th_debug & TOPO_DBG_MOD)) return; va_start(alist, format); - topo_vdprintf(mod->tm_hdl, TOPO_DBG_MOD, (const char *)mod->tm_name, - format, alist); + topo_vdprintf(mod->tm_hdl, (const char *)mod->tm_name, format, alist); va_end(alist); } diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_subr.c b/usr/src/lib/fm/topo/libtopo/common/topo_subr.c index 8d9408dd59..e5c5e4052d 100644 --- a/usr/src/lib/fm/topo/libtopo/common/topo_subr.c +++ b/usr/src/lib/fm/topo/libtopo/common/topo_subr.c @@ -172,16 +172,12 @@ topo_debug_set(topo_hdl_t *thp, const char *dbmode, const char *dout) } void -topo_vdprintf(topo_hdl_t *thp, int mask, const char *mod, const char *format, - va_list ap) +topo_vdprintf(topo_hdl_t *thp, const char *mod, const char *format, va_list ap) { char *msg; size_t len; char c; - if (!(thp->th_debug & mask)) - return; - len = vsnprintf(&c, 1, format, ap); msg = alloca(len + 2); (void) vsnprintf(msg, len + 1, format, ap); @@ -212,8 +208,11 @@ topo_dprintf(topo_hdl_t *thp, int mask, const char *format, ...) { va_list ap; + if (!(thp->th_debug & mask)) + return; + va_start(ap, format); - topo_vdprintf(thp, mask, NULL, format, ap); + topo_vdprintf(thp, NULL, format, ap); va_end(ap); } diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_subr.h b/usr/src/lib/fm/topo/libtopo/common/topo_subr.h index ecb076b08a..073fd382e5 100644 --- a/usr/src/lib/fm/topo/libtopo/common/topo_subr.h +++ b/usr/src/lib/fm/topo/libtopo/common/topo_subr.h @@ -21,6 +21,7 @@ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. */ #ifndef _TOPO_SUBR_H @@ -124,7 +125,7 @@ extern int topo_version_str2num(const char *, topo_version_t); extern int topo_version_defined(topo_version_t); extern void topo_dprintf(topo_hdl_t *, int, const char *, ...); -extern void topo_vdprintf(topo_hdl_t *, int, const char *, const char *, +extern void topo_vdprintf(topo_hdl_t *, const char *, const char *, va_list); extern tnode_t *topo_hdl_root(topo_hdl_t *, const char *); |
