| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: printf.c,v 1.2 2018/05/28 21:05:09 chs Exp $ */ | | 1 | /* $NetBSD: printf.c,v 1.3 2020/03/03 06:44:38 riastradh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * CDDL HEADER START | | 4 | * CDDL HEADER START |
5 | * | | 5 | * |
6 | * The contents of this file are subject to the terms of the | | 6 | * The contents of this file are subject to the terms of the |
7 | * Common Development and Distribution License (the "License"). | | 7 | * Common Development and Distribution License (the "License"). |
8 | * You may not use this file except in compliance with the License. | | 8 | * You may not use this file except in compliance with the License. |
9 | * | | 9 | * |
10 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | | 10 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
11 | * or http://www.opensolaris.org/os/licensing. | | 11 | * or http://www.opensolaris.org/os/licensing. |
12 | * See the License for the specific language governing permissions | | 12 | * See the License for the specific language governing permissions |
13 | * and limitations under the License. | | 13 | * and limitations under the License. |
14 | * | | 14 | * |
| @@ -31,30 +31,28 @@ | | | @@ -31,30 +31,28 @@ |
31 | #include <sys/types.h> | | 31 | #include <sys/types.h> |
32 | #include <sys/systm.h> | | 32 | #include <sys/systm.h> |
33 | #include <sys/cmn_err.h> | | 33 | #include <sys/cmn_err.h> |
34 | | | 34 | |
35 | static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" }; | | 35 | static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" }; |
36 | static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" }; | | 36 | static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" }; |
37 | | | 37 | |
38 | void | | 38 | void |
39 | vcmn_err(int ce, const char *fmt, va_list adx) | | 39 | vcmn_err(int ce, const char *fmt, va_list adx) |
40 | { | | 40 | { |
41 | char buf[256]; | | 41 | char buf[256]; |
42 | size_t len; | | 42 | size_t len; |
43 | | | 43 | |
44 | if (ce == CE_PANIC) { | | 44 | if (ce == CE_PANIC) |
45 | vprintf(fmt, adx); | | 45 | vpanic(fmt, adx); |
46 | panic("panic"); | | | |
47 | } | | | |
48 | | | 46 | |
49 | if ((uint_t)ce < CE_IGNORE) { | | 47 | if ((uint_t)ce < CE_IGNORE) { |
50 | strcpy(buf, ce_prefix[ce]); | | 48 | strcpy(buf, ce_prefix[ce]); |
51 | len = strlen(buf); | | 49 | len = strlen(buf); |
52 | vsnprintf(buf + len, sizeof(buf) - len, | | 50 | vsnprintf(buf + len, sizeof(buf) - len, |
53 | fmt, adx); | | 51 | fmt, adx); |
54 | strlcat(buf, ce_suffix[ce], sizeof(buf)); | | 52 | strlcat(buf, ce_suffix[ce], sizeof(buf)); |
55 | printf("%s", buf); | | 53 | printf("%s", buf); |
56 | } | | 54 | } |
57 | } | | 55 | } |
58 | | | 56 | |
59 | void | | 57 | void |
60 | cmn_err(int ce, const char *fmt, ...) | | 58 | cmn_err(int ce, const char *fmt, ...) |