diff options
author | avg <avg@FreeBSD.org> | 2011-12-19 14:55:14 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2011-12-19 14:55:14 +0000 |
commit | 45e7ecc66ae5db3d7eaa312817bfadd0af045c18 (patch) | |
tree | 453d4334874ac5f3a8be071cfc57f0b448284d35 | |
parent | 7240dddfccf6e401bb5e36ff502227462cc927d4 (diff) | |
download | FreeBSD-src-45e7ecc66ae5db3d7eaa312817bfadd0af045c18.zip FreeBSD-src-45e7ecc66ae5db3d7eaa312817bfadd0af045c18.tar.gz |
opensolaris compat: fix vcmn_err so that panic(9) produces a proper message
... instead of just a verbatim format string.
Reviewed by: pjd
MFC after: 1 week
-rw-r--r-- | sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c b/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c index 12e1854..abde30d 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c @@ -28,29 +28,35 @@ void vcmn_err(int ce, const char *fmt, va_list adx) { char buf[256]; + const char *prefix; + prefix = NULL; /* silence unwitty compilers */ switch (ce) { case CE_CONT: - snprintf(buf, sizeof(buf), "Solaris(cont): %s\n", fmt); + prefix = "Solaris(cont): "; break; case CE_NOTE: - snprintf(buf, sizeof(buf), "Solaris: NOTICE: %s\n", fmt); + prefix = "Solaris: NOTICE: "; break; case CE_WARN: - snprintf(buf, sizeof(buf), "Solaris: WARNING: %s\n", fmt); + prefix = "Solaris: WARNING: "; break; case CE_PANIC: - snprintf(buf, sizeof(buf), "Solaris(panic): %s\n", fmt); + prefix = "Solaris(panic): "; break; case CE_IGNORE: break; default: panic("Solaris: unknown severity level"); } - if (ce == CE_PANIC) - panic("%s", buf); - if (ce != CE_IGNORE) - vprintf(buf, adx); + if (ce == CE_PANIC) { + vsnprintf(buf, sizeof(buf), fmt, adx); + panic("%s%s", prefix, buf); + } + if (ce != CE_IGNORE) { + printf("%s", prefix); + vprintf(fmt, adx); + } } void |