lint: clean up messages for internal errorsdiff -r1.17 -r1.18 src/usr.bin/xlint/common/emit.c
(rillig)
--- src/usr.bin/xlint/common/emit.c 2022/05/20 21:18:54 1.17
+++ src/usr.bin/xlint/common/emit.c 2023/01/14 09:30:07 1.18
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: emit.c,v 1.17 2022/05/20 21:18:54 rillig Exp $ */ | 1 | /* $NetBSD: emit.c,v 1.18 2023/01/14 09:30:07 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994, 1995 Jochen Pohl | 4 | * Copyright (c) 1994, 1995 Jochen Pohl | |
5 | * All Rights Reserved. | 5 | * All Rights Reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #if HAVE_NBTOOL_CONFIG_H | 34 | #if HAVE_NBTOOL_CONFIG_H | |
35 | #include "nbtool_config.h" | 35 | #include "nbtool_config.h" | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | #if defined(__RCSID) | 39 | #if defined(__RCSID) | |
40 | __RCSID("$NetBSD: emit.c,v 1.17 2022/05/20 21:18:54 rillig Exp $"); | 40 | __RCSID("$NetBSD: emit.c,v 1.18 2023/01/14 09:30:07 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <stdio.h> | 43 | #include <stdio.h> | |
44 | #include <string.h> | 44 | #include <string.h> | |
45 | 45 | |||
46 | #include "lint.h" | 46 | #include "lint.h" | |
47 | 47 | |||
48 | /* name and handle of output file */ | 48 | /* name and handle of output file */ | |
49 | static const char *loname; | 49 | static const char *loname; | |
50 | static FILE *lout; | 50 | static FILE *lout; | |
51 | 51 | |||
52 | /* output buffer data */ | 52 | /* output buffer data */ | |
53 | static ob_t ob; | 53 | static ob_t ob; | |
@@ -102,27 +102,27 @@ outxbuf(void) | @@ -102,27 +102,27 @@ outxbuf(void) | |||
102 | /* | 102 | /* | |
103 | * reset output buffer | 103 | * reset output buffer | |
104 | * if it is not empty, it is flushed | 104 | * if it is not empty, it is flushed | |
105 | */ | 105 | */ | |
106 | void | 106 | void | |
107 | outclr(void) | 107 | outclr(void) | |
108 | { | 108 | { | |
109 | size_t sz; | 109 | size_t sz; | |
110 | 110 | |||
111 | if (ob.o_buf != ob.o_next) { | 111 | if (ob.o_buf != ob.o_next) { | |
112 | outchar('\n'); | 112 | outchar('\n'); | |
113 | sz = ob.o_next - ob.o_buf; | 113 | sz = ob.o_next - ob.o_buf; | |
114 | if (sz > ob.o_len) | 114 | if (sz > ob.o_len) | |
115 | errx(1, "internal error: outclr() 1"); | 115 | errx(1, "internal error: outclr"); | |
116 | if (fwrite(ob.o_buf, sz, 1, lout) != 1) | 116 | if (fwrite(ob.o_buf, sz, 1, lout) != 1) | |
117 | err(1, "cannot write to %s", loname); | 117 | err(1, "cannot write to %s", loname); | |
118 | ob.o_next = ob.o_buf; | 118 | ob.o_next = ob.o_buf; | |
119 | } | 119 | } | |
120 | } | 120 | } | |
121 | 121 | |||
122 | /* | 122 | /* | |
123 | * write a character to the output buffer | 123 | * write a character to the output buffer | |
124 | */ | 124 | */ | |
125 | void | 125 | void | |
126 | outchar(char c) | 126 | outchar(char c) | |
127 | { | 127 | { | |
128 | 128 |
--- src/usr.bin/xlint/lint2/emit2.c 2022/05/20 21:18:55 1.28
+++ src/usr.bin/xlint/lint2/emit2.c 2023/01/14 09:30:07 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: emit2.c,v 1.28 2022/05/20 21:18:55 rillig Exp $ */ | 1 | /* $NetBSD: emit2.c,v 1.29 2023/01/14 09:30:07 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
5 | * Copyright (c) 1994, 1995 Jochen Pohl | 5 | * Copyright (c) 1994, 1995 Jochen Pohl | |
6 | * All Rights Reserved. | 6 | * All Rights Reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | #if defined(__RCSID) | 36 | #if defined(__RCSID) | |
37 | __RCSID("$NetBSD: emit2.c,v 1.28 2022/05/20 21:18:55 rillig Exp $"); | 37 | __RCSID("$NetBSD: emit2.c,v 1.29 2023/01/14 09:30:07 rillig Exp $"); | |
38 | #endif | 38 | #endif | |
39 | 39 | |||
40 | #include "lint2.h" | 40 | #include "lint2.h" | |
41 | 41 | |||
42 | static void outtype(type_t *); | 42 | static void outtype(type_t *); | |
43 | static void outdef(hte_t *, sym_t *); | 43 | static void outdef(hte_t *, sym_t *); | |
44 | static void dumpname(hte_t *); | 44 | static void dumpname(hte_t *); | |
45 | static void outfiles(void); | 45 | static void outfiles(void); | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | * Write type into the output buffer. | 48 | * Write type into the output buffer. | |
49 | */ | 49 | */ | |
50 | static void | 50 | static void | |
@@ -84,27 +84,27 @@ outtype(type_t *tp) | @@ -84,27 +84,27 @@ outtype(type_t *tp) | |||
84 | outint(1); | 84 | outint(1); | |
85 | outname(tp->t_tag->h_name); | 85 | outname(tp->t_tag->h_name); | |
86 | } else if (tp->t_istynam) { | 86 | } else if (tp->t_istynam) { | |
87 | outint(2); | 87 | outint(2); | |
88 | outname(tp->t_tynam->h_name); | 88 | outname(tp->t_tynam->h_name); | |
89 | } else if (tp->t_isuniqpos) { | 89 | } else if (tp->t_isuniqpos) { | |
90 | outint(3); | 90 | outint(3); | |
91 | outint(tp->t_uniqpos.p_line); | 91 | outint(tp->t_uniqpos.p_line); | |
92 | outchar('.'); | 92 | outchar('.'); | |
93 | outint(tp->t_uniqpos.p_file); | 93 | outint(tp->t_uniqpos.p_file); | |
94 | outchar('.'); | 94 | outchar('.'); | |
95 | outint(tp->t_uniqpos.p_uniq); | 95 | outint(tp->t_uniqpos.p_uniq); | |
96 | } else | 96 | } else | |
97 | errx(1, "internal error: outtype() 2"); | 97 | errx(1, "internal error: outtype"); | |
98 | } else if (ts == FUNC && tp->t_args != NULL) { | 98 | } else if (ts == FUNC && tp->t_args != NULL) { | |
99 | na = 0; | 99 | na = 0; | |
100 | for (ap = tp->t_args; *ap != NULL; ap++) | 100 | for (ap = tp->t_args; *ap != NULL; ap++) | |
101 | na++; | 101 | na++; | |
102 | if (tp->t_vararg) | 102 | if (tp->t_vararg) | |
103 | na++; | 103 | na++; | |
104 | outint(na); | 104 | outint(na); | |
105 | for (ap = tp->t_args; *ap != NULL; ap++) | 105 | for (ap = tp->t_args; *ap != NULL; ap++) | |
106 | outtype(*ap); | 106 | outtype(*ap); | |
107 | if (tp->t_vararg) | 107 | if (tp->t_vararg) | |
108 | outchar('E'); | 108 | outchar('E'); | |
109 | } | 109 | } | |
110 | tp = tp->t_subt; | 110 | tp = tp->t_subt; | |
@@ -179,27 +179,27 @@ dumpname(hte_t *hte) | @@ -179,27 +179,27 @@ dumpname(hte_t *hte) | |||
179 | * definition. This is necessary because more than one tentative | 179 | * definition. This is necessary because more than one tentative | |
180 | * definition is allowed (except with sflag). | 180 | * definition is allowed (except with sflag). | |
181 | */ | 181 | */ | |
182 | def = NULL; | 182 | def = NULL; | |
183 | for (sym = hte->h_syms; sym != NULL; sym = sym->s_next) { | 183 | for (sym = hte->h_syms; sym != NULL; sym = sym->s_next) { | |
184 | if (sym->s_def == DEF) { | 184 | if (sym->s_def == DEF) { | |
185 | def = sym; | 185 | def = sym; | |
186 | break; | 186 | break; | |
187 | } | 187 | } | |
188 | if (sym->s_def == TDEF && def == NULL) | 188 | if (sym->s_def == TDEF && def == NULL) | |
189 | def = sym; | 189 | def = sym; | |
190 | } | 190 | } | |
191 | if (def == NULL) | 191 | if (def == NULL) | |
192 | errx(1, "internal error: dumpname() %s", hte->h_name); | 192 | errx(1, "internal error: dumpname %s", hte->h_name); | |
193 | 193 | |||
194 | outdef(hte, def); | 194 | outdef(hte, def); | |
195 | } | 195 | } | |
196 | 196 | |||
197 | /* | 197 | /* | |
198 | * Write a new lint library. | 198 | * Write a new lint library. | |
199 | */ | 199 | */ | |
200 | void | 200 | void | |
201 | outlib(const char *name) | 201 | outlib(const char *name) | |
202 | { | 202 | { | |
203 | /* Open of output file and initialization of the output buffer */ | 203 | /* Open of output file and initialization of the output buffer */ | |
204 | outopen(name); | 204 | outopen(name); | |
205 | 205 |
--- src/usr.bin/xlint/lint2/read.c 2023/01/13 19:50:00 1.77
+++ src/usr.bin/xlint/lint2/read.c 2023/01/14 09:30:07 1.78
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: read.c,v 1.77 2023/01/13 19:50:00 rillig Exp $ */ | 1 | /* $NetBSD: read.c,v 1.78 2023/01/14 09:30:07 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
5 | * Copyright (c) 1994, 1995 Jochen Pohl | 5 | * Copyright (c) 1994, 1995 Jochen Pohl | |
6 | * All Rights Reserved. | 6 | * All Rights Reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #if HAVE_NBTOOL_CONFIG_H | 35 | #if HAVE_NBTOOL_CONFIG_H | |
36 | #include "nbtool_config.h" | 36 | #include "nbtool_config.h" | |
37 | #endif | 37 | #endif | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | #if defined(__RCSID) | 40 | #if defined(__RCSID) | |
41 | __RCSID("$NetBSD: read.c,v 1.77 2023/01/13 19:50:00 rillig Exp $"); | 41 | __RCSID("$NetBSD: read.c,v 1.78 2023/01/14 09:30:07 rillig Exp $"); | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <ctype.h> | 44 | #include <ctype.h> | |
45 | #include <limits.h> | 45 | #include <limits.h> | |
46 | #include <stdarg.h> | 46 | #include <stdarg.h> | |
47 | #include <stdio.h> | 47 | #include <stdio.h> | |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> | |
49 | #include <string.h> | 49 | #include <string.h> | |
50 | 50 | |||
51 | #include "lint2.h" | 51 | #include "lint2.h" | |
52 | 52 | |||
53 | 53 | |||
54 | /* index of current (included) source file */ | 54 | /* index of current (included) source file */ | |
@@ -295,27 +295,27 @@ setfnid(int fid, const char *cp) | @@ -295,27 +295,27 @@ setfnid(int fid, const char *cp) | |||
295 | if (fid < 0) | 295 | if (fid < 0) | |
296 | inperr("bad fid"); | 296 | inperr("bad fid"); | |
297 | 297 | |||
298 | if ((size_t)fid >= ninpfns) { | 298 | if ((size_t)fid >= ninpfns) { | |
299 | inpfns = xrealloc(inpfns, (ninpfns * 2) * sizeof(*inpfns)); | 299 | inpfns = xrealloc(inpfns, (ninpfns * 2) * sizeof(*inpfns)); | |
300 | (void)memset(inpfns + ninpfns, 0, ninpfns * sizeof(*inpfns)); | 300 | (void)memset(inpfns + ninpfns, 0, ninpfns * sizeof(*inpfns)); | |
301 | ninpfns *= 2; | 301 | ninpfns *= 2; | |
302 | } | 302 | } | |
303 | /* | 303 | /* | |
304 | * Should always be true because indices written in the output | 304 | * Should always be true because indices written in the output | |
305 | * file by lint1 are always the previous index + 1. | 305 | * file by lint1 are always the previous index + 1. | |
306 | */ | 306 | */ | |
307 | if ((size_t)fid >= ninpfns) | 307 | if ((size_t)fid >= ninpfns) | |
308 | errx(1, "internal error: setfnid()"); | 308 | errx(1, "internal error: setfnid"); | |
309 | inpfns[fid] = (unsigned short)getfnidx(cp); | 309 | inpfns[fid] = (unsigned short)getfnidx(cp); | |
310 | } | 310 | } | |
311 | 311 | |||
312 | /* | 312 | /* | |
313 | * Process a function call record (c-record). | 313 | * Process a function call record (c-record). | |
314 | */ | 314 | */ | |
315 | static void | 315 | static void | |
316 | funccall(pos_t pos, const char *cp) | 316 | funccall(pos_t pos, const char *cp) | |
317 | { | 317 | { | |
318 | arginf_t *ai, **lai; | 318 | arginf_t *ai, **lai; | |
319 | char c; | 319 | char c; | |
320 | bool rused, rdisc; | 320 | bool rused, rdisc; | |
321 | hte_t *hte; | 321 | hte_t *hte; |