lint: fix typos and other minor stylistic issuesdiff -r1.21 -r1.22 src/usr.bin/xlint/common/tyname.c
(rillig)
--- src/usr.bin/xlint/common/tyname.c 2021/01/03 15:55:18 1.21
+++ src/usr.bin/xlint/common/tyname.c 2021/01/04 22:26:50 1.22
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tyname.c,v 1.21 2021/01/03 15:55:18 rillig Exp $ */ | 1 | /* $NetBSD: tyname.c,v 1.22 2021/01/04 22:26:50 rillig Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2005 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2005 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Christos Zoulas. | 8 | * by Christos Zoulas. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #if HAVE_NBTOOL_CONFIG_H | 32 | #if HAVE_NBTOOL_CONFIG_H | |
33 | #include "nbtool_config.h" | 33 | #include "nbtool_config.h" | |
34 | #endif | 34 | #endif | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | #if defined(__RCSID) && !defined(lint) | 37 | #if defined(__RCSID) && !defined(lint) | |
38 | __RCSID("$NetBSD: tyname.c,v 1.21 2021/01/03 15:55:18 rillig Exp $"); | 38 | __RCSID("$NetBSD: tyname.c,v 1.22 2021/01/04 22:26:50 rillig Exp $"); | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #include <limits.h> | 41 | #include <limits.h> | |
42 | #include <string.h> | 42 | #include <string.h> | |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> | |
44 | #include <err.h> | 44 | #include <err.h> | |
45 | 45 | |||
46 | #include PASS | 46 | #include PASS | |
47 | 47 | |||
48 | #ifndef LERROR | 48 | #ifndef LERROR | |
49 | #define LERROR(fmt, args...) \ | 49 | #define LERROR(fmt, args...) \ | |
50 | do { \ | 50 | do { \ | |
51 | (void)warnx("%s, %d: " fmt, __FILE__, __LINE__, ##args); \ | 51 | (void)warnx("%s, %d: " fmt, __FILE__, __LINE__, ##args); \ | |
@@ -270,27 +270,27 @@ type_name_of_function(buffer *buf, const | @@ -270,27 +270,27 @@ type_name_of_function(buffer *buf, const | |||
270 | buf_add(buf, sep), sep = ", "; | 270 | buf_add(buf, sep), sep = ", "; | |
271 | buf_add(buf, type_name(arg->s_type)); | 271 | buf_add(buf, type_name(arg->s_type)); | |
272 | } | 272 | } | |
273 | #else /* lint2 */ | 273 | #else /* lint2 */ | |
274 | type_t **argtype; | 274 | type_t **argtype; | |
275 | 275 | |||
276 | for (argtype = tp->t_args; *argtype != NULL; argtype++) { | 276 | for (argtype = tp->t_args; *argtype != NULL; argtype++) { | |
277 | buf_add(buf, sep), sep = ", "; | 277 | buf_add(buf, sep), sep = ", "; | |
278 | buf_add(buf, type_name(*argtype)); | 278 | buf_add(buf, type_name(*argtype)); | |
279 | } | 279 | } | |
280 | #endif | 280 | #endif | |
281 | } | 281 | } | |
282 | if (tp->t_vararg) { | 282 | if (tp->t_vararg) { | |
283 | buf_add(buf, sep), sep = ", "; | 283 | buf_add(buf, sep); | |
284 | buf_add(buf, "..."); | 284 | buf_add(buf, "..."); | |
285 | } | 285 | } | |
286 | buf_add(buf, ") returning "); | 286 | buf_add(buf, ") returning "); | |
287 | buf_add(buf, type_name(tp->t_subt)); | 287 | buf_add(buf, type_name(tp->t_subt)); | |
288 | } | 288 | } | |
289 | 289 | |||
290 | const char * | 290 | const char * | |
291 | type_name(const type_t *tp) | 291 | type_name(const type_t *tp) | |
292 | { | 292 | { | |
293 | tspec_t t; | 293 | tspec_t t; | |
294 | buffer buf; | 294 | buffer buf; | |
295 | const char *name; | 295 | const char *name; | |
296 | 296 |
--- src/usr.bin/xlint/lint1/decl.c 2021/01/03 20:14:38 1.110
+++ src/usr.bin/xlint/lint1/decl.c 2021/01/04 22:26:50 1.111
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: decl.c,v 1.110 2021/01/03 20:14:38 rillig Exp $ */ | 1 | /* $NetBSD: decl.c,v 1.111 2021/01/04 22:26:50 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,39 +28,39 @@ | @@ -28,39 +28,39 @@ | |||
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) && !defined(lint) | 40 | #if defined(__RCSID) && !defined(lint) | |
41 | __RCSID("$NetBSD: decl.c,v 1.110 2021/01/03 20:14:38 rillig Exp $"); | 41 | __RCSID("$NetBSD: decl.c,v 1.111 2021/01/04 22:26:50 rillig Exp $"); | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <limits.h> | 45 | #include <limits.h> | |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> | |
47 | #include <string.h> | 47 | #include <string.h> | |
48 | 48 | |||
49 | #include "lint1.h" | 49 | #include "lint1.h" | |
50 | 50 | |||
51 | const char *unnamed = "<unnamed>"; | 51 | const char *unnamed = "<unnamed>"; | |
52 | 52 | |||
53 | /* shared type structures for arithmtic types and void */ | 53 | /* shared type structures for arithmetic types and void */ | |
54 | static type_t *typetab; | 54 | static type_t *typetab; | |
55 | 55 | |||
56 | /* value of next enumerator during declaration of enum types */ | 56 | /* value of next enumerator during declaration of enum types */ | |
57 | int enumval; | 57 | int enumval; | |
58 | 58 | |||
59 | /* | 59 | /* | |
60 | * pointer to top element of a stack which contains information local | 60 | * pointer to top element of a stack which contains information local | |
61 | * to nested declarations | 61 | * to nested declarations | |
62 | */ | 62 | */ | |
63 | dinfo_t *dcs; | 63 | dinfo_t *dcs; | |
64 | 64 | |||
65 | static type_t *tdeferr(type_t *, tspec_t); | 65 | static type_t *tdeferr(type_t *, tspec_t); | |
66 | static void settdsym(type_t *, sym_t *); | 66 | static void settdsym(type_t *, sym_t *); | |
@@ -662,27 +662,27 @@ popdecl(void) | @@ -662,27 +662,27 @@ popdecl(void) | |||
662 | /* FALLTHROUGH */ | 662 | /* FALLTHROUGH */ | |
663 | default: | 663 | default: | |
664 | lint_assert(/*CONSTCOND*/0); | 664 | lint_assert(/*CONSTCOND*/0); | |
665 | } | 665 | } | |
666 | free(di); | 666 | free(di); | |
667 | } | 667 | } | |
668 | 668 | |||
669 | /* | 669 | /* | |
670 | * Set flag d_asm in all declaration stack elements up to the | 670 | * Set flag d_asm in all declaration stack elements up to the | |
671 | * outermost one. | 671 | * outermost one. | |
672 | * | 672 | * | |
673 | * This is used to mark compound statements which have, possibly in | 673 | * This is used to mark compound statements which have, possibly in | |
674 | * nested compound statements, asm statements. For these compound | 674 | * nested compound statements, asm statements. For these compound | |
675 | * statements no warnings about unused or unitialized variables are | 675 | * statements no warnings about unused or uninitialized variables are | |
676 | * printed. | 676 | * printed. | |
677 | * | 677 | * | |
678 | * There is no need to clear d_asm in dinfo structs with context AUTO, | 678 | * There is no need to clear d_asm in dinfo structs with context AUTO, | |
679 | * because these structs are freed at the end of the compound statement. | 679 | * because these structs are freed at the end of the compound statement. | |
680 | * But it must be cleared in the outermost dinfo struct, which has | 680 | * But it must be cleared in the outermost dinfo struct, which has | |
681 | * context EXTERN. This could be done in clrtyp() and would work for | 681 | * context EXTERN. This could be done in clrtyp() and would work for | |
682 | * C, but not for C++ (due to mixed statements and declarations). Thus | 682 | * C, but not for C++ (due to mixed statements and declarations). Thus | |
683 | * we clear it in global_clean_up_decl(), which is used to do some cleanup | 683 | * we clear it in global_clean_up_decl(), which is used to do some cleanup | |
684 | * after global declarations/definitions. | 684 | * after global declarations/definitions. | |
685 | */ | 685 | */ | |
686 | void | 686 | void | |
687 | setasm(void) | 687 | setasm(void) | |
688 | { | 688 | { | |
@@ -867,27 +867,27 @@ merge_type_specifiers(tspec_t t, tspec_t | @@ -867,27 +867,27 @@ merge_type_specifiers(tspec_t t, tspec_t | |||
867 | } else if (t == LONG) { | 867 | } else if (t == LONG) { | |
868 | t = s == SIGNED ? LONG : ULONG; | 868 | t = s == SIGNED ? LONG : ULONG; | |
869 | } else if (t == QUAD) { | 869 | } else if (t == QUAD) { | |
870 | t = s == SIGNED ? QUAD : UQUAD; | 870 | t = s == SIGNED ? QUAD : UQUAD; | |
871 | } | 871 | } | |
872 | } | 872 | } | |
873 | 873 | |||
874 | return t; | 874 | return t; | |
875 | } | 875 | } | |
876 | 876 | |||
877 | /* | 877 | /* | |
878 | * Return the length of a type in bits. | 878 | * Return the length of a type in bits. | |
879 | * | 879 | * | |
880 | * Printing a message if the outhermost dimension of an array is 0 must | 880 | * Printing a message if the outermost dimension of an array is 0 must | |
881 | * be done by the caller. All other problems are reported by length() | 881 | * be done by the caller. All other problems are reported by length() | |
882 | * if name is not NULL. | 882 | * if name is not NULL. | |
883 | */ | 883 | */ | |
884 | int | 884 | int | |
885 | length(type_t *tp, const char *name) | 885 | length(type_t *tp, const char *name) | |
886 | { | 886 | { | |
887 | int elem, elsz; | 887 | int elem, elsz; | |
888 | 888 | |||
889 | elem = 1; | 889 | elem = 1; | |
890 | while (tp && tp->t_tspec == ARRAY) { | 890 | while (tp && tp->t_tspec == ARRAY) { | |
891 | elem *= tp->t_dim; | 891 | elem *= tp->t_dim; | |
892 | tp = tp->t_subt; | 892 | tp = tp->t_subt; | |
893 | } | 893 | } | |
@@ -967,27 +967,27 @@ lnklst(sym_t *l1, sym_t *l2) | @@ -967,27 +967,27 @@ lnklst(sym_t *l1, sym_t *l2) | |||
967 | if ((l = l1) == NULL) | 967 | if ((l = l1) == NULL) | |
968 | return l2; | 968 | return l2; | |
969 | while (l1->s_next != NULL) | 969 | while (l1->s_next != NULL) | |
970 | l1 = l1->s_next; | 970 | l1 = l1->s_next; | |
971 | l1->s_next = l2; | 971 | l1->s_next = l2; | |
972 | return l; | 972 | return l; | |
973 | } | 973 | } | |
974 | 974 | |||
975 | /* | 975 | /* | |
976 | * Check if the type of the given symbol is valid and print an error | 976 | * Check if the type of the given symbol is valid and print an error | |
977 | * message if it is not. | 977 | * message if it is not. | |
978 | * | 978 | * | |
979 | * Invalid types are: | 979 | * Invalid types are: | |
980 | * - arrays of incomlete types or functions | 980 | * - arrays of incomplete types or functions | |
981 | * - functions returning arrays or functions | 981 | * - functions returning arrays or functions | |
982 | * - void types other than type of function or pointer | 982 | * - void types other than type of function or pointer | |
983 | */ | 983 | */ | |
984 | void | 984 | void | |
985 | check_type(sym_t *sym) | 985 | check_type(sym_t *sym) | |
986 | { | 986 | { | |
987 | tspec_t to, t; | 987 | tspec_t to, t; | |
988 | type_t **tpp, *tp; | 988 | type_t **tpp, *tp; | |
989 | 989 | |||
990 | tpp = &sym->s_type; | 990 | tpp = &sym->s_type; | |
991 | to = NOTSPEC; | 991 | to = NOTSPEC; | |
992 | while ((tp = *tpp) != NULL) { | 992 | while ((tp = *tpp) != NULL) { | |
993 | t = tp->t_tspec; | 993 | t = tp->t_tspec; | |
@@ -1888,27 +1888,27 @@ decl1ext(sym_t *dsym, int initflg) | @@ -1888,27 +1888,27 @@ decl1ext(sym_t *dsym, int initflg) | |||
1888 | if (dcs->d_inline) { | 1888 | if (dcs->d_inline) { | |
1889 | if (dsym->s_type->t_tspec == FUNC) { | 1889 | if (dsym->s_type->t_tspec == FUNC) { | |
1890 | dsym->s_inline = 1; | 1890 | dsym->s_inline = 1; | |
1891 | } else { | 1891 | } else { | |
1892 | /* variable declared inline: %s */ | 1892 | /* variable declared inline: %s */ | |
1893 | warning(268, dsym->s_name); | 1893 | warning(268, dsym->s_name); | |
1894 | } | 1894 | } | |
1895 | } | 1895 | } | |
1896 | 1896 | |||
1897 | /* Write the declaration into the output file */ | 1897 | /* Write the declaration into the output file */ | |
1898 | if (plibflg && llibflg && | 1898 | if (plibflg && llibflg && | |
1899 | dsym->s_type->t_tspec == FUNC && dsym->s_type->t_proto) { | 1899 | dsym->s_type->t_tspec == FUNC && dsym->s_type->t_proto) { | |
1900 | /* | 1900 | /* | |
1901 | * With both LINTLIBRARY and PROTOLIB the prototyp is | 1901 | * With both LINTLIBRARY and PROTOLIB the prototype is | |
1902 | * written as a function definition to the output file. | 1902 | * written as a function definition to the output file. | |
1903 | */ | 1903 | */ | |
1904 | rval = dsym->s_type->t_subt->t_tspec != VOID; | 1904 | rval = dsym->s_type->t_subt->t_tspec != VOID; | |
1905 | outfdef(dsym, &dsym->s_def_pos, rval, 0, NULL); | 1905 | outfdef(dsym, &dsym->s_def_pos, rval, 0, NULL); | |
1906 | } else { | 1906 | } else { | |
1907 | outsym(dsym, dsym->s_scl, dsym->s_def); | 1907 | outsym(dsym, dsym->s_scl, dsym->s_def); | |
1908 | } | 1908 | } | |
1909 | 1909 | |||
1910 | if ((rdsym = dcs->d_rdcsym) != NULL) { | 1910 | if ((rdsym = dcs->d_rdcsym) != NULL) { | |
1911 | 1911 | |||
1912 | /* | 1912 | /* | |
1913 | * If the old symbol stems from an old style function | 1913 | * If the old symbol stems from an old style function | |
1914 | * definition, we have remembered the params in rdsmy->s_args | 1914 | * definition, we have remembered the params in rdsmy->s_args |
--- src/usr.bin/xlint/lint1/emit1.c 2021/01/03 20:14:38 1.33
+++ src/usr.bin/xlint/lint1/emit1.c 2021/01/04 22:26:50 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: emit1.c,v 1.33 2021/01/03 20:14:38 rillig Exp $ */ | 1 | /* $NetBSD: emit1.c,v 1.34 2021/01/04 22:26:50 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) && !defined(lint) | 40 | #if defined(__RCSID) && !defined(lint) | |
41 | __RCSID("$NetBSD: emit1.c,v 1.33 2021/01/03 20:14:38 rillig Exp $"); | 41 | __RCSID("$NetBSD: emit1.c,v 1.34 2021/01/04 22:26:50 rillig Exp $"); | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <ctype.h> | 44 | #include <ctype.h> | |
45 | 45 | |||
46 | #include "lint1.h" | 46 | #include "lint1.h" | |
47 | 47 | |||
48 | static void outtt(sym_t *, sym_t *); | 48 | static void outtt(sym_t *, sym_t *); | |
49 | static void outfstrg(strg_t *); | 49 | static void outfstrg(strg_t *); | |
50 | 50 | |||
51 | /* | 51 | /* | |
52 | * Write type into the output buffer. | 52 | * Write type into the output buffer. | |
53 | * The type is written as a sequence of substrings, each of which describes a | 53 | * The type is written as a sequence of substrings, each of which describes a | |
54 | * node of type type_t | 54 | * node of type type_t | |
@@ -78,27 +78,27 @@ static void outfstrg(strg_t *); | @@ -78,27 +78,27 @@ static void outfstrg(strg_t *); | |||
78 | * (void) F 0 | 78 | * (void) F 0 | |
79 | * (n arguments) F n arg1 arg2 ... argn | 79 | * (n arguments) F n arg1 arg2 ... argn | |
80 | * (n arguments, ...) F n arg1 arg2 ... argn-1 E | 80 | * (n arguments, ...) F n arg1 arg2 ... argn-1 E | |
81 | * (a, b, c, ...) f n arg1 arg2 ... | 81 | * (a, b, c, ...) f n arg1 arg2 ... | |
82 | * enum tag e T tag_or_typename | 82 | * enum tag e T tag_or_typename | |
83 | * struct tag s T tag_or_typename | 83 | * struct tag s T tag_or_typename | |
84 | * union tag u T tag_or_typename | 84 | * union tag u T tag_or_typename | |
85 | * | 85 | * | |
86 | * tag_or_typename 0 no tag or type name | 86 | * tag_or_typename 0 no tag or type name | |
87 | * 1 n tag Tag | 87 | * 1 n tag Tag | |
88 | * 2 n typename only type name | 88 | * 2 n typename only type name | |
89 | * | 89 | * | |
90 | * spaces are only for better readability | 90 | * spaces are only for better readability | |
91 | * additionaly it is possible to prepend the characters 'c' (for const) | 91 | * additionally it is possible to prepend the characters 'c' (for const) | |
92 | * and 'v' (for volatile) | 92 | * and 'v' (for volatile) | |
93 | */ | 93 | */ | |
94 | void | 94 | void | |
95 | outtype(type_t *tp) | 95 | outtype(type_t *tp) | |
96 | { | 96 | { | |
97 | int t, s, na; | 97 | int t, s, na; | |
98 | sym_t *arg; | 98 | sym_t *arg; | |
99 | tspec_t ts; | 99 | tspec_t ts; | |
100 | 100 | |||
101 | while (tp != NULL) { | 101 | while (tp != NULL) { | |
102 | if ((ts = tp->t_tspec) == INT && tp->t_isenum) | 102 | if ((ts = tp->t_tspec) == INT && tp->t_isenum) | |
103 | ts = ENUM; | 103 | ts = ENUM; | |
104 | switch (ts) { | 104 | switch (ts) { | |
@@ -391,27 +391,27 @@ outfdef(sym_t *fsym, pos_t *posp, int rv | @@ -391,27 +391,27 @@ outfdef(sym_t *fsym, pos_t *posp, int rv | |||
391 | outint(narg); | 391 | outint(narg); | |
392 | for (arg = args; arg != NULL; arg = arg->s_next) | 392 | for (arg = args; arg != NULL; arg = arg->s_next) | |
393 | outtype(arg->s_type); | 393 | outtype(arg->s_type); | |
394 | outtype(fsym->s_type->t_subt); | 394 | outtype(fsym->s_type->t_subt); | |
395 | } else { | 395 | } else { | |
396 | outtype(fsym->s_type); | 396 | outtype(fsym->s_type); | |
397 | } | 397 | } | |
398 | } | 398 | } | |
399 | 399 | |||
400 | /* | 400 | /* | |
401 | * write out all information necessary for lint2 to check function | 401 | * write out all information necessary for lint2 to check function | |
402 | * calls | 402 | * calls | |
403 | * | 403 | * | |
404 | * rvused is set if the return value is used (asigned to a variable) | 404 | * rvused is set if the return value is used (assigned to a variable) | |
405 | * rvdisc is set if the return value is not used and not ignored | 405 | * rvdisc is set if the return value is not used and not ignored | |
406 | * (casted to void) | 406 | * (casted to void) | |
407 | */ | 407 | */ | |
408 | void | 408 | void | |
409 | outcall(tnode_t *tn, int rvused, int rvdisc) | 409 | outcall(tnode_t *tn, int rvused, int rvdisc) | |
410 | { | 410 | { | |
411 | tnode_t *args, *arg; | 411 | tnode_t *args, *arg; | |
412 | int narg, n, i; | 412 | int narg, n, i; | |
413 | int64_t q; | 413 | int64_t q; | |
414 | tspec_t t; | 414 | tspec_t t; | |
415 | 415 | |||
416 | /* reset buffer */ | 416 | /* reset buffer */ | |
417 | outclr(); | 417 | outclr(); | |
@@ -480,27 +480,27 @@ outcall(tnode_t *tn, int rvused, int rvd | @@ -480,27 +480,27 @@ outcall(tnode_t *tn, int rvused, int rvd | |||
480 | outint(narg); | 480 | outint(narg); | |
481 | for (n = 1; n <= narg; n++) { | 481 | for (n = 1; n <= narg; n++) { | |
482 | /* the last argument is the top one in the tree */ | 482 | /* the last argument is the top one in the tree */ | |
483 | for (i = narg, arg = args; i > n; i--, arg = arg->tn_right) | 483 | for (i = narg, arg = args; i > n; i--, arg = arg->tn_right) | |
484 | continue; | 484 | continue; | |
485 | outtype(arg->tn_left->tn_type); | 485 | outtype(arg->tn_left->tn_type); | |
486 | } | 486 | } | |
487 | /* expected type of return value */ | 487 | /* expected type of return value */ | |
488 | outtype(tn->tn_type); | 488 | outtype(tn->tn_type); | |
489 | } | 489 | } | |
490 | 490 | |||
491 | /* | 491 | /* | |
492 | * extracts potential format specifiers for printf() and scanf() and | 492 | * extracts potential format specifiers for printf() and scanf() and | |
493 | * writes them, enclosed in "" and qouted if necessary, to the output buffer | 493 | * writes them, enclosed in "" and quoted if necessary, to the output buffer | |
494 | */ | 494 | */ | |
495 | static void | 495 | static void | |
496 | outfstrg(strg_t *strg) | 496 | outfstrg(strg_t *strg) | |
497 | { | 497 | { | |
498 | int c, oc, first; | 498 | int c, oc, first; | |
499 | u_char *cp; | 499 | u_char *cp; | |
500 | 500 | |||
501 | lint_assert(strg->st_tspec == CHAR); | 501 | lint_assert(strg->st_tspec == CHAR); | |
502 | 502 | |||
503 | cp = strg->st_cp; | 503 | cp = strg->st_cp; | |
504 | 504 | |||
505 | outchar('"'); | 505 | outchar('"'); | |
506 | 506 |
--- src/usr.bin/xlint/lint1/func.c 2021/01/03 20:14:38 1.49
+++ src/usr.bin/xlint/lint1/func.c 2021/01/04 22:26:50 1.50
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: func.c,v 1.49 2021/01/03 20:14:38 rillig Exp $ */ | 1 | /* $NetBSD: func.c,v 1.50 2021/01/04 22:26:50 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,60 +27,60 @@ | @@ -27,60 +27,60 @@ | |||
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) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: func.c,v 1.49 2021/01/03 20:14:38 rillig Exp $"); | 40 | __RCSID("$NetBSD: func.c,v 1.50 2021/01/04 22:26:50 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> | |
44 | #include <string.h> | 44 | #include <string.h> | |
45 | 45 | |||
46 | #include "lint1.h" | 46 | #include "lint1.h" | |
47 | #include "cgram.h" | 47 | #include "cgram.h" | |
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * Contains a pointer to the symbol table entry of the current function | 50 | * Contains a pointer to the symbol table entry of the current function | |
51 | * definition. | 51 | * definition. | |
52 | */ | 52 | */ | |
53 | sym_t *funcsym; | 53 | sym_t *funcsym; | |
54 | 54 | |||
55 | /* Is set as long as a statement can be reached. Must be set at level 0. */ | 55 | /* Is set as long as a statement can be reached. Must be set at level 0. */ | |
56 | int reached = 1; | 56 | int reached = 1; | |
57 | 57 | |||
58 | /* | 58 | /* | |
59 | * Is set as long as NOTREACHED is in effect. | 59 | * Is set as long as NOTREACHED is in effect. | |
60 | * Is reset everywhere where reached can become 0. | 60 | * Is reset everywhere where reached can become 0. | |
61 | */ | 61 | */ | |
62 | int rchflg; | 62 | int rchflg; | |
63 | 63 | |||
64 | /* | 64 | /* | |
65 | * In conjunction with reached ontrols printing of "fallthrough on ..." | 65 | * In conjunction with reached, controls printing of "fallthrough on ..." | |
66 | * warnings. | 66 | * warnings. | |
67 | * Reset by each statement and set by FALLTHROUGH, switch (switch1()) | 67 | * Reset by each statement and set by FALLTHROUGH, switch (switch1()) | |
68 | * and case (label()). | 68 | * and case (label()). | |
69 | * | 69 | * | |
70 | * Control statements if, for, while and switch do not reset ftflg because | 70 | * Control statements if, for, while and switch do not reset ftflg because | |
71 | * this must be done by the controlled statement. At least for if this is | 71 | * this must be done by the controlled statement. At least for if this is | |
72 | * important because ** FALLTHROUGH ** after "if (expr) stmnt" is evaluated | 72 | * important because ** FALLTHROUGH ** after "if (expr) stmnt" is evaluated | |
73 | * before the following token, wich causes reduction of above. | 73 | * before the following token, which causes reduction of above. | |
74 | * This means that ** FALLTHROUGH ** after "if ..." would always be ignored. | 74 | * This means that ** FALLTHROUGH ** after "if ..." would always be ignored. | |
75 | */ | 75 | */ | |
76 | int ftflg; | 76 | int ftflg; | |
77 | 77 | |||
78 | /* The innermost control statement */ | 78 | /* The innermost control statement */ | |
79 | cstk_t *cstmt; | 79 | cstk_t *cstmt; | |
80 | 80 | |||
81 | /* | 81 | /* | |
82 | * Number of arguments which will be checked for usage in following | 82 | * Number of arguments which will be checked for usage in following | |
83 | * function definition. -1 stands for all arguments. | 83 | * function definition. -1 stands for all arguments. | |
84 | * | 84 | * | |
85 | * The position of the last ARGSUSED comment is stored in argsused_pos. | 85 | * The position of the last ARGSUSED comment is stored in argsused_pos. | |
86 | */ | 86 | */ | |
@@ -284,28 +284,32 @@ funcdef(sym_t *fsym) | @@ -284,28 +284,32 @@ funcdef(sym_t *fsym) | |||
284 | */ | 284 | */ | |
285 | dcs->d_fdpos = fsym->s_def_pos; | 285 | dcs->d_fdpos = fsym->s_def_pos; | |
286 | 286 | |||
287 | if ((rdsym = dcs->d_rdcsym) != NULL) { | 287 | if ((rdsym = dcs->d_rdcsym) != NULL) { | |
288 | 288 | |||
289 | if (!check_redeclaration(fsym, (dowarn = 0, &dowarn))) { | 289 | if (!check_redeclaration(fsym, (dowarn = 0, &dowarn))) { | |
290 | 290 | |||
291 | /* | 291 | /* | |
292 | * Print nothing if the newly defined function | 292 | * Print nothing if the newly defined function | |
293 | * is defined in old style. A better warning will | 293 | * is defined in old style. A better warning will | |
294 | * be printed in check_func_lint_directives(). | 294 | * be printed in check_func_lint_directives(). | |
295 | */ | 295 | */ | |
296 | if (dowarn && !fsym->s_osdef) { | 296 | if (dowarn && !fsym->s_osdef) { | |
297 | /* redeclaration of %s */ | 297 | if (sflag) | |
298 | (*(sflag ? error : warning))(27, fsym->s_name); | 298 | /* redeclaration of %s */ | |
299 | error(27, fsym->s_name); | |||
300 | else | |||
301 | /* redeclaration of %s */ | |||
302 | warning(27, fsym->s_name); | |||
299 | print_previous_declaration(-1, rdsym); | 303 | print_previous_declaration(-1, rdsym); | |
300 | } | 304 | } | |
301 | 305 | |||
302 | /* copy usage information */ | 306 | /* copy usage information */ | |
303 | copy_usage_info(fsym, rdsym); | 307 | copy_usage_info(fsym, rdsym); | |
304 | 308 | |||
305 | /* | 309 | /* | |
306 | * If the old symbol was a prototype and the new | 310 | * If the old symbol was a prototype and the new | |
307 | * one is none, overtake the position of the | 311 | * one is none, overtake the position of the | |
308 | * declaration of the prototype. | 312 | * declaration of the prototype. | |
309 | */ | 313 | */ | |
310 | if (fsym->s_osdef && rdsym->s_type->t_proto) | 314 | if (fsym->s_osdef && rdsym->s_type->t_proto) | |
311 | fsym->s_def_pos = rdsym->s_def_pos; | 315 | fsym->s_def_pos = rdsym->s_def_pos; | |
@@ -1178,27 +1182,27 @@ scanflike(int n) | @@ -1178,27 +1182,27 @@ scanflike(int n) | |||
1178 | /* must be outside function: ** %s ** */ | 1182 | /* must be outside function: ** %s ** */ | |
1179 | warning(280, "SCANFLIKE"); | 1183 | warning(280, "SCANFLIKE"); | |
1180 | return; | 1184 | return; | |
1181 | } | 1185 | } | |
1182 | if (scanflike_argnum != -1) { | 1186 | if (scanflike_argnum != -1) { | |
1183 | /* duplicate use of ** %s ** */ | 1187 | /* duplicate use of ** %s ** */ | |
1184 | warning(281, "SCANFLIKE"); | 1188 | warning(281, "SCANFLIKE"); | |
1185 | } | 1189 | } | |
1186 | scanflike_argnum = n; | 1190 | scanflike_argnum = n; | |
1187 | scanflike_pos = curr_pos; | 1191 | scanflike_pos = curr_pos; | |
1188 | } | 1192 | } | |
1189 | 1193 | |||
1190 | /* | 1194 | /* | |
1191 | * Set the linenumber for a CONSTCOND comment. At this and the following | 1195 | * Set the line number for a CONSTCOND comment. At this and the following | |
1192 | * line no warnings about constants in conditional contexts are printed. | 1196 | * line no warnings about constants in conditional contexts are printed. | |
1193 | */ | 1197 | */ | |
1194 | /* ARGSUSED */ | 1198 | /* ARGSUSED */ | |
1195 | void | 1199 | void | |
1196 | constcond(int n) | 1200 | constcond(int n) | |
1197 | { | 1201 | { | |
1198 | 1202 | |||
1199 | constcond_flag = 1; | 1203 | constcond_flag = 1; | |
1200 | } | 1204 | } | |
1201 | 1205 | |||
1202 | /* | 1206 | /* | |
1203 | * Suppress printing of "fallthrough on ..." warnings until next | 1207 | * Suppress printing of "fallthrough on ..." warnings until next | |
1204 | * statement. | 1208 | * statement. |
--- src/usr.bin/xlint/lint1/lint1.h 2021/01/03 20:04:08 1.52
+++ src/usr.bin/xlint/lint1/lint1.h 2021/01/04 22:26:50 1.53
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lint1.h,v 1.52 2021/01/03 20:04:08 rillig Exp $ */ | 1 | /* $NetBSD: lint1.h,v 1.53 2021/01/04 22:26:50 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 | |
@@ -41,29 +41,29 @@ | @@ -41,29 +41,29 @@ | |||
41 | * not depend on the host settings but the target settings in determining | 41 | * not depend on the host settings but the target settings in determining | |
42 | * the alignment. The only valid use for this is in mem1.c; uses in decl.c | 42 | * the alignment. The only valid use for this is in mem1.c; uses in decl.c | |
43 | * are bogus. | 43 | * are bogus. | |
44 | */ | 44 | */ | |
45 | #ifndef WORST_ALIGN | 45 | #ifndef WORST_ALIGN | |
46 | #ifdef _LP64 | 46 | #ifdef _LP64 | |
47 | # define AVAL 15 | 47 | # define AVAL 15 | |
48 | #else | 48 | #else | |
49 | # define AVAL 7 | 49 | # define AVAL 7 | |
50 | #endif | 50 | #endif | |
51 | #define WORST_ALIGN(x) (((x) + AVAL) & ~AVAL) | 51 | #define WORST_ALIGN(x) (((x) + AVAL) & ~AVAL) | |
52 | #endif | 52 | #endif | |
53 | 53 | |||
54 | #define LWARN_BAD -3 | 54 | #define LWARN_BAD (-3) | |
55 | #define LWARN_ALL -2 | 55 | #define LWARN_ALL (-2) | |
56 | #define LWARN_NONE -1 | 56 | #define LWARN_NONE (-1) | |
57 | 57 | |||
58 | /* | 58 | /* | |
59 | * Describes the position of a declaration or anything else. | 59 | * Describes the position of a declaration or anything else. | |
60 | */ | 60 | */ | |
61 | typedef struct { | 61 | typedef struct { | |
62 | int p_line; | 62 | int p_line; | |
63 | const char *p_file; | 63 | const char *p_file; | |
64 | int p_uniq; /* uniquifier */ | 64 | int p_uniq; /* uniquifier */ | |
65 | } pos_t; | 65 | } pos_t; | |
66 | 66 | |||
67 | /* Copies curr_pos, keeping things unique. */ | 67 | /* Copies curr_pos, keeping things unique. */ | |
68 | #define UNIQUE_CURR_POS(pos) \ | 68 | #define UNIQUE_CURR_POS(pos) \ | |
69 | do { \ | 69 | do { \ | |
@@ -106,27 +106,27 @@ typedef struct { | @@ -106,27 +106,27 @@ typedef struct { | |||
106 | tspec_t v_tspec; | 106 | tspec_t v_tspec; | |
107 | int v_ansiu; /* set if an integer constant is | 107 | int v_ansiu; /* set if an integer constant is | |
108 | unsigned in ANSI C */ | 108 | unsigned in ANSI C */ | |
109 | union { | 109 | union { | |
110 | int64_t _v_quad; /* integers */ | 110 | int64_t _v_quad; /* integers */ | |
111 | ldbl_t _v_ldbl; /* floats */ | 111 | ldbl_t _v_ldbl; /* floats */ | |
112 | } v_u; | 112 | } v_u; | |
113 | } val_t; | 113 | } val_t; | |
114 | 114 | |||
115 | #define v_quad v_u._v_quad | 115 | #define v_quad v_u._v_quad | |
116 | #define v_ldbl v_u._v_ldbl | 116 | #define v_ldbl v_u._v_ldbl | |
117 | 117 | |||
118 | /* | 118 | /* | |
119 | * Structures of type str_t uniqely identify structures. This can't | 119 | * Structures of type str_t uniquely identify structures. This can't | |
120 | * be done in structures of type type_t, because these are copied | 120 | * be done in structures of type type_t, because these are copied | |
121 | * if they must be modified. So it would not be possible to check | 121 | * if they must be modified. So it would not be possible to check | |
122 | * if two structures are identical by comparing the pointers to | 122 | * if two structures are identical by comparing the pointers to | |
123 | * the type structures. | 123 | * the type structures. | |
124 | * | 124 | * | |
125 | * The typename is used if the structure is unnamed to identify | 125 | * The typename is used if the structure is unnamed to identify | |
126 | * the structure type in pass 2. | 126 | * the structure type in pass 2. | |
127 | */ | 127 | */ | |
128 | typedef struct { | 128 | typedef struct { | |
129 | u_int size; /* size in bit */ | 129 | u_int size; /* size in bit */ | |
130 | u_int align : 15; /* alignment in bit */ | 130 | u_int align : 15; /* alignment in bit */ | |
131 | bool sincompl : 1; /* set if incomplete type */ | 131 | bool sincompl : 1; /* set if incomplete type */ | |
132 | struct sym *memb; /* list of members */ | 132 | struct sym *memb; /* list of members */ |
--- src/usr.bin/xlint/lint1/main1.c 2020/12/29 11:35:11 1.31
+++ src/usr.bin/xlint/lint1/main1.c 2021/01/04 22:26:50 1.32
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: main1.c,v 1.31 2020/12/29 11:35:11 rillig Exp $ */ | 1 | /* $NetBSD: main1.c,v 1.32 2021/01/04 22:26:50 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,45 +27,45 @@ | @@ -27,45 +27,45 @@ | |||
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) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: main1.c,v 1.31 2020/12/29 11:35:11 rillig Exp $"); | 40 | __RCSID("$NetBSD: main1.c,v 1.32 2021/01/04 22:26:50 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <sys/types.h> | 43 | #include <sys/types.h> | |
44 | #include <errno.h> | 44 | #include <errno.h> | |
45 | #include <limits.h> | 45 | #include <limits.h> | |
46 | #include <signal.h> | 46 | #include <signal.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 | #include <unistd.h> | 50 | #include <unistd.h> | |
51 | 51 | |||
52 | #include "lint1.h" | 52 | #include "lint1.h" | |
53 | 53 | |||
54 | /* set yydebug to 1*/ | 54 | /* set yydebug to 1*/ | |
55 | int yflag; | 55 | int yflag; | |
56 | 56 | |||
57 | /* | 57 | /* | |
58 | * Print warnings if an assignment of an integertype to another integertype | 58 | * Print warnings if an assignment of an integer type to another integer type | |
59 | * causes an implicit narrowing conversion. If aflag is 1, these warnings | 59 | * causes an implicit narrowing conversion. If aflag is 1, these warnings | |
60 | * are printed only if the source type is at least as wide as long. If aflag | 60 | * are printed only if the source type is at least as wide as long. If aflag | |
61 | * is greater than 1, they are always printed. | 61 | * is greater than 1, they are always printed. | |
62 | */ | 62 | */ | |
63 | int aflag; | 63 | int aflag; | |
64 | 64 | |||
65 | /* Print a warning if a break statement cannot be reached. */ | 65 | /* Print a warning if a break statement cannot be reached. */ | |
66 | int bflag; | 66 | int bflag; | |
67 | 67 | |||
68 | /* Print warnings for pointer casts. */ | 68 | /* Print warnings for pointer casts. */ | |
69 | int cflag; | 69 | int cflag; | |
70 | 70 | |||
71 | /* Print various debug information. */ | 71 | /* Print various debug information. */ |
--- src/usr.bin/xlint/lint1/scan.l 2021/01/03 17:42:45 1.111
+++ src/usr.bin/xlint/lint1/scan.l 2021/01/04 22:26:50 1.112
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | %{ | 1 | %{ | |
2 | /* $NetBSD: scan.l,v 1.111 2021/01/03 17:42:45 rillig Exp $ */ | 2 | /* $NetBSD: scan.l,v 1.112 2021/01/04 22:26:50 rillig Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 5 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
6 | * Copyright (c) 1994, 1995 Jochen Pohl | 6 | * Copyright (c) 1994, 1995 Jochen Pohl | |
7 | * All Rights Reserved. | 7 | * All Rights Reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | #if defined(__RCSID) && !defined(lint) | 37 | #if defined(__RCSID) && !defined(lint) | |
38 | __RCSID("$NetBSD: scan.l,v 1.111 2021/01/03 17:42:45 rillig Exp $"); | 38 | __RCSID("$NetBSD: scan.l,v 1.112 2021/01/04 22:26:50 rillig Exp $"); | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #include <ctype.h> | 41 | #include <ctype.h> | |
42 | #include <errno.h> | 42 | #include <errno.h> | |
43 | #include <float.h> | 43 | #include <float.h> | |
44 | #include <limits.h> | 44 | #include <limits.h> | |
45 | #include <math.h> | 45 | #include <math.h> | |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> | |
47 | #include <string.h> | 47 | #include <string.h> | |
48 | 48 | |||
49 | #include "lint1.h" | 49 | #include "lint1.h" | |
50 | #include "cgram.h" | 50 | #include "cgram.h" | |
51 | 51 | |||
@@ -1330,27 +1330,27 @@ slashslashcomment(void) | @@ -1330,27 +1330,27 @@ slashslashcomment(void) | |||
1330 | * the controlling expression and the body of control statements | 1330 | * the controlling expression and the body of control statements | |
1331 | * (if, switch, for, while). | 1331 | * (if, switch, for, while). | |
1332 | */ | 1332 | */ | |
1333 | void | 1333 | void | |
1334 | clrwflgs(void) | 1334 | clrwflgs(void) | |
1335 | { | 1335 | { | |
1336 | 1336 | |||
1337 | lwarn = LWARN_ALL; | 1337 | lwarn = LWARN_ALL; | |
1338 | quadflg = 0; | 1338 | quadflg = 0; | |
1339 | constcond_flag = 0; | 1339 | constcond_flag = 0; | |
1340 | } | 1340 | } | |
1341 | 1341 | |||
1342 | /* | 1342 | /* | |
1343 | * Strings are stored in a dynamically alloceted buffer and passed | 1343 | * Strings are stored in a dynamically allocated buffer and passed | |
1344 | * in yylval.y_xstrg to the parser. The parser or the routines called | 1344 | * in yylval.y_xstrg to the parser. The parser or the routines called | |
1345 | * by the parser are responsible for freeing this buffer. | 1345 | * by the parser are responsible for freeing this buffer. | |
1346 | */ | 1346 | */ | |
1347 | static int | 1347 | static int | |
1348 | string(void) | 1348 | string(void) | |
1349 | { | 1349 | { | |
1350 | u_char *s; | 1350 | u_char *s; | |
1351 | int c; | 1351 | int c; | |
1352 | size_t len, max; | 1352 | size_t len, max; | |
1353 | strg_t *strg; | 1353 | strg_t *strg; | |
1354 | 1354 | |||
1355 | s = xmalloc(max = 64); | 1355 | s = xmalloc(max = 64); | |
1356 | 1356 |
--- src/usr.bin/xlint/lint1/tree.c 2021/01/04 21:30:06 1.126
+++ src/usr.bin/xlint/lint1/tree.c 2021/01/04 22:26:50 1.127
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tree.c,v 1.126 2021/01/04 21:30:06 rillig Exp $ */ | 1 | /* $NetBSD: tree.c,v 1.127 2021/01/04 22:26:50 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) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: tree.c,v 1.126 2021/01/04 21:30:06 rillig Exp $"); | 40 | __RCSID("$NetBSD: tree.c,v 1.127 2021/01/04 22:26:50 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <float.h> | 43 | #include <float.h> | |
44 | #include <limits.h> | 44 | #include <limits.h> | |
45 | #include <math.h> | 45 | #include <math.h> | |
46 | #include <signal.h> | 46 | #include <signal.h> | |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> | |
48 | #include <string.h> | 48 | #include <string.h> | |
49 | 49 | |||
50 | #include "lint1.h" | 50 | #include "lint1.h" | |
51 | #include "cgram.h" | 51 | #include "cgram.h" | |
52 | 52 | |||
53 | static tnode_t *new_integer_constant_node(tspec_t, int64_t); | 53 | static tnode_t *new_integer_constant_node(tspec_t, int64_t); | |
@@ -1335,27 +1335,27 @@ check_bad_enum_operation(op_t op, tnode_ | @@ -1335,27 +1335,27 @@ check_bad_enum_operation(op_t op, tnode_ | |||
1335 | 1335 | |||
1336 | if (!eflag) | 1336 | if (!eflag) | |
1337 | return; | 1337 | return; | |
1338 | 1338 | |||
1339 | mp = &modtab[op]; | 1339 | mp = &modtab[op]; | |
1340 | 1340 | |||
1341 | if (!(ln->tn_type->t_isenum || | 1341 | if (!(ln->tn_type->t_isenum || | |
1342 | (mp->m_binary && rn->tn_type->t_isenum))) { | 1342 | (mp->m_binary && rn->tn_type->t_isenum))) { | |
1343 | return; | 1343 | return; | |
1344 | } | 1344 | } | |
1345 | 1345 | |||
1346 | /* | 1346 | /* | |
1347 | * Enum as offset to a pointer is an exception (otherwise enums | 1347 | * Enum as offset to a pointer is an exception (otherwise enums | |
1348 | * could not be used as array indizes). | 1348 | * could not be used as array indices). | |
1349 | */ | 1349 | */ | |
1350 | if (op == PLUS && | 1350 | if (op == PLUS && | |
1351 | ((ln->tn_type->t_isenum && rn->tn_type->t_tspec == PTR) || | 1351 | ((ln->tn_type->t_isenum && rn->tn_type->t_tspec == PTR) || | |
1352 | (rn->tn_type->t_isenum && ln->tn_type->t_tspec == PTR))) { | 1352 | (rn->tn_type->t_isenum && ln->tn_type->t_tspec == PTR))) { | |
1353 | return; | 1353 | return; | |
1354 | } | 1354 | } | |
1355 | 1355 | |||
1356 | /* dubious operation on enum, op %s */ | 1356 | /* dubious operation on enum, op %s */ | |
1357 | warning(241, mp->m_name); | 1357 | warning(241, mp->m_name); | |
1358 | 1358 | |||
1359 | } | 1359 | } | |
1360 | 1360 | |||
1361 | /* | 1361 | /* |
--- src/usr.bin/xlint/lint2/chk.c 2021/01/02 03:49:26 1.31
+++ src/usr.bin/xlint/lint2/chk.c 2021/01/04 22:26:51 1.32
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: chk.c,v 1.31 2021/01/02 03:49:26 rillig Exp $ */ | 1 | /* $NetBSD: chk.c,v 1.32 2021/01/04 22:26:51 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) && !defined(lint) | 40 | #if defined(__RCSID) && !defined(lint) | |
41 | __RCSID("$NetBSD: chk.c,v 1.31 2021/01/02 03:49:26 rillig Exp $"); | 41 | __RCSID("$NetBSD: chk.c,v 1.32 2021/01/04 22:26:51 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 <stdlib.h> | 46 | #include <stdlib.h> | |
47 | #include <string.h> | 47 | #include <string.h> | |
48 | 48 | |||
49 | #include "lint2.h" | 49 | #include "lint2.h" | |
50 | 50 | |||
51 | static void chkund(hte_t *); | 51 | static void chkund(hte_t *); | |
52 | static void chkdnu(hte_t *); | 52 | static void chkdnu(hte_t *); | |
53 | static void chkdnud(hte_t *); | 53 | static void chkdnud(hte_t *); | |
54 | static void chkmd(hte_t *); | 54 | static void chkmd(hte_t *); | |
@@ -271,27 +271,27 @@ chkvtui(hte_t *hte, sym_t *def, sym_t *d | @@ -271,27 +271,27 @@ chkvtui(hte_t *hte, sym_t *def, sym_t *d | |||
271 | * behaviour matches pcc based lint, so it is | 271 | * behaviour matches pcc based lint, so it is | |
272 | * accepted for now. | 272 | * accepted for now. | |
273 | */ | 273 | */ | |
274 | pos1 = xstrdup(mkpos(&def->s_pos)); | 274 | pos1 = xstrdup(mkpos(&def->s_pos)); | |
275 | /* %s value must be decl. before use %s :: %s */ | 275 | /* %s value must be decl. before use %s :: %s */ | |
276 | msg(17, hte->h_name, | 276 | msg(17, hte->h_name, | |
277 | pos1, mkpos(&call->f_pos)); | 277 | pos1, mkpos(&call->f_pos)); | |
278 | free(pos1); | 278 | free(pos1); | |
279 | } | 279 | } | |
280 | continue; | 280 | continue; | |
281 | } | 281 | } | |
282 | if (!eq || (sflag && dowarn)) { | 282 | if (!eq || (sflag && dowarn)) { | |
283 | pos1 = xstrdup(mkpos(&def->s_pos)); | 283 | pos1 = xstrdup(mkpos(&def->s_pos)); | |
284 | /* %s value used inconsistenty\t%s :: %s */ | 284 | /* %s value used inconsistently\t%s :: %s */ | |
285 | msg(4, hte->h_name, pos1, mkpos(&call->f_pos)); | 285 | msg(4, hte->h_name, pos1, mkpos(&call->f_pos)); | |
286 | free(pos1); | 286 | free(pos1); | |
287 | } | 287 | } | |
288 | } | 288 | } | |
289 | } | 289 | } | |
290 | 290 | |||
291 | /* | 291 | /* | |
292 | * Print a warning if a definition/declaration does not match another | 292 | * Print a warning if a definition/declaration does not match another | |
293 | * definition/declaration of the same name. For functions, only the | 293 | * definition/declaration of the same name. For functions, only the | |
294 | * types of return values are tested. | 294 | * types of return values are tested. | |
295 | */ | 295 | */ | |
296 | static void | 296 | static void | |
297 | chkvtdi(hte_t *hte, sym_t *def, sym_t *decl) | 297 | chkvtdi(hte_t *hte, sym_t *def, sym_t *decl) | |
@@ -442,71 +442,71 @@ chkfaui(hte_t *hte, sym_t *def, sym_t *d | @@ -442,71 +442,71 @@ chkfaui(hte_t *hte, sym_t *def, sym_t *d | |||
442 | * arg2 currently checked argument of call | 442 | * arg2 currently checked argument of call | |
443 | * | 443 | * | |
444 | */ | 444 | */ | |
445 | static void | 445 | static void | |
446 | chkau(hte_t *hte, int n, sym_t *def, sym_t *decl, pos_t *pos1p, | 446 | chkau(hte_t *hte, int n, sym_t *def, sym_t *decl, pos_t *pos1p, | |
447 | fcall_t *call1, fcall_t *call, type_t *arg1, type_t *arg2) | 447 | fcall_t *call1, fcall_t *call, type_t *arg1, type_t *arg2) | |
448 | { | 448 | { | |
449 | int promote, asgn, dowarn; | 449 | int promote, asgn, dowarn; | |
450 | tspec_t t1, t2; | 450 | tspec_t t1, t2; | |
451 | arginf_t *ai, *ai1; | 451 | arginf_t *ai, *ai1; | |
452 | char *pos1; | 452 | char *pos1; | |
453 | 453 | |||
454 | /* | 454 | /* | |
455 | * If a function definition is available (def != NULL), we compair the | 455 | * If a function definition is available (def != NULL), we compare the | |
456 | * function call (call) with the definition. Otherwise, if a function | 456 | * function call (call) with the definition. Otherwise, if a function | |
457 | * definition is available and it is not an old style definition | 457 | * definition is available and it is not an old style definition | |
458 | * (decl != NULL && TP(decl->s_type)->t_proto), we compair the call | 458 | * (decl != NULL && TP(decl->s_type)->t_proto), we compare the call | |
459 | * with this declaration. Otherwise we compair it with the first | 459 | * with this declaration. Otherwise we compare it with the first | |
460 | * call we have found (call1). | 460 | * call we have found (call1). | |
461 | */ | 461 | */ | |
462 | 462 | |||
463 | /* arg1 must be promoted if it stems from an old style definition */ | 463 | /* arg1 must be promoted if it stems from an old style definition */ | |
464 | promote = def != NULL && def->s_osdef; | 464 | promote = def != NULL && def->s_osdef; | |
465 | 465 | |||
466 | /* | 466 | /* | |
467 | * If we compair with a definition or declaration, we must perform | 467 | * If we compare with a definition or declaration, we must perform | |
468 | * the same checks for qualifiers in indirected types as in | 468 | * the same checks for qualifiers in indirected types as in | |
469 | * assignments. | 469 | * assignments. | |
470 | */ | 470 | */ | |
471 | asgn = def != NULL || (decl != NULL && TP(decl->s_type)->t_proto); | 471 | asgn = def != NULL || (decl != NULL && TP(decl->s_type)->t_proto); | |
472 | 472 | |||
473 | dowarn = 0; | 473 | dowarn = 0; | |
474 | if (eqtype(arg1, arg2, 1, promote, asgn, &dowarn) && (!sflag || !dowarn)) | 474 | if (eqtype(arg1, arg2, 1, promote, asgn, &dowarn) && (!sflag || !dowarn)) | |
475 | return; | 475 | return; | |
476 | 476 | |||
477 | /* | 477 | /* | |
478 | * Other lint implementations print warnings as soon as the type | 478 | * Other lint implementations print warnings as soon as the type | |
479 | * of an argument does not match exactly the expected type. The | 479 | * of an argument does not match exactly the expected type. The | |
480 | * result are lots of warnings which are really not necessary. | 480 | * result are lots of warnings which are really not necessary. | |
481 | * We print a warning only if | 481 | * We print a warning only if | |
482 | * (0) at least one type is not an interger type and types differ | 482 | * (0) at least one type is not an integer type and types differ | |
483 | * (1) hflag is set and types differ | 483 | * (1) hflag is set and types differ | |
484 | * (2) types differ, except in signedness | 484 | * (2) types differ, except in signedness | |
485 | * If the argument is an integer constant whose msb is not set, | 485 | * If the argument is an integer constant whose msb is not set, | |
486 | * signedness is ignored (e.g. 0 matches both signed and unsigned | 486 | * signedness is ignored (e.g. 0 matches both signed and unsigned | |
487 | * int). This is with and without hflag. | 487 | * int). This is with and without hflag. | |
488 | * If the argument is an integer constant with value 0 and the | 488 | * If the argument is an integer constant with value 0 and the | |
489 | * expected argument is of type pointer and the width of the | 489 | * expected argument is of type pointer and the width of the | |
490 | * interger constant is the same as the width of the pointer, | 490 | * integer constant is the same as the width of the pointer, | |
491 | * no warning is printed. | 491 | * no warning is printed. | |
492 | */ | 492 | */ | |
493 | t1 = arg1->t_tspec; | 493 | t1 = arg1->t_tspec; | |
494 | t2 = arg2->t_tspec; | 494 | t2 = arg2->t_tspec; | |
495 | if (tspec_is_int(t1) && tspec_is_int(t2) && | 495 | if (tspec_is_int(t1) && tspec_is_int(t2) && | |
496 | !arg1->t_isenum && !arg2->t_isenum) { | 496 | !arg1->t_isenum && !arg2->t_isenum) { | |
497 | if (promote) { | 497 | if (promote) { | |
498 | /* | 498 | /* | |
499 | * XXX Here is a problem: Althrough it is possible to | 499 | * XXX Here is a problem: Although it is possible to | |
500 | * pass an int where a char/short it expected, there | 500 | * pass an int where a char/short it expected, there | |
501 | * may be loss in significant digits. We should first | 501 | * may be loss in significant digits. We should first | |
502 | * check for const arguments if they can be converted | 502 | * check for const arguments if they can be converted | |
503 | * into the original parameter type. | 503 | * into the original parameter type. | |
504 | */ | 504 | */ | |
505 | if (t1 == FLOAT) { | 505 | if (t1 == FLOAT) { | |
506 | t1 = DOUBLE; | 506 | t1 = DOUBLE; | |
507 | } else if (t1 == CHAR || t1 == SCHAR) { | 507 | } else if (t1 == CHAR || t1 == SCHAR) { | |
508 | t1 = INT; | 508 | t1 = INT; | |
509 | } else if (t1 == UCHAR) { | 509 | } else if (t1 == UCHAR) { | |
510 | t1 = tflag ? UINT : INT; | 510 | t1 = tflag ? UINT : INT; | |
511 | } else if (t1 == SHORT) { | 511 | } else if (t1 == SHORT) { | |
512 | t1 = INT; | 512 | t1 = INT; | |
@@ -920,36 +920,36 @@ scanflike(hte_t *hte, fcall_t *call, int | @@ -920,36 +920,36 @@ scanflike(hte_t *hte, fcall_t *call, int | |||
920 | } else if (fc == 'D') { | 920 | } else if (fc == 'D') { | |
921 | if (sz != NOTSPEC || !tflag) | 921 | if (sz != NOTSPEC || !tflag) | |
922 | badfmt(hte, call); | 922 | badfmt(hte, call); | |
923 | sz = LONG; | 923 | sz = LONG; | |
924 | goto conv; | 924 | goto conv; | |
925 | } else if (fc == 'O') { | 925 | } else if (fc == 'O') { | |
926 | if (sz != NOTSPEC || !tflag) | 926 | if (sz != NOTSPEC || !tflag) | |
927 | badfmt(hte, call); | 927 | badfmt(hte, call); | |
928 | sz = ULONG; | 928 | sz = ULONG; | |
929 | goto conv; | 929 | goto conv; | |
930 | } else if (fc == 'X') { | 930 | } else if (fc == 'X') { | |
931 | /* | 931 | /* | |
932 | * XXX valid in ANSI C, but in NetBSD's libc imple- | 932 | * XXX valid in ANSI C, but in NetBSD's libc imple- | |
933 | * mented as "lx". Thats why it should be avoided. | 933 | * mented as "lx". That's why it should be avoided. | |
934 | */ | 934 | */ | |
935 | if (sz != NOTSPEC || !tflag) | 935 | if (sz != NOTSPEC || !tflag) | |
936 | badfmt(hte, call); | 936 | badfmt(hte, call); | |
937 | sz = ULONG; | 937 | sz = ULONG; | |
938 | goto conv; | 938 | goto conv; | |
939 | } else if (fc == 'E') { | 939 | } else if (fc == 'E') { | |
940 | /* | 940 | /* | |
941 | * XXX valid in ANSI C, but in NetBSD's libc imple- | 941 | * XXX valid in ANSI C, but in NetBSD's libc imple- | |
942 | * mented as "lf". Thats why it should be avoided. | 942 | * mented as "lf". That's why it should be avoided. | |
943 | */ | 943 | */ | |
944 | if (sz != NOTSPEC || !tflag) | 944 | if (sz != NOTSPEC || !tflag) | |
945 | badfmt(hte, call); | 945 | badfmt(hte, call); | |
946 | sz = DOUBLE; | 946 | sz = DOUBLE; | |
947 | goto conv; | 947 | goto conv; | |
948 | } else if (fc == 'F') { | 948 | } else if (fc == 'F') { | |
949 | /* XXX only for backward compatibility */ | 949 | /* XXX only for backward compatibility */ | |
950 | if (sz != NOTSPEC || !tflag) | 950 | if (sz != NOTSPEC || !tflag) | |
951 | badfmt(hte, call); | 951 | badfmt(hte, call); | |
952 | sz = DOUBLE; | 952 | sz = DOUBLE; | |
953 | goto conv; | 953 | goto conv; | |
954 | } else if (fc == 'G') { | 954 | } else if (fc == 'G') { | |
955 | /* | 955 | /* | |
@@ -1069,27 +1069,27 @@ chkrvu(hte_t *hte, sym_t *def) | @@ -1069,27 +1069,27 @@ chkrvu(hte_t *hte, sym_t *def) | |||
1069 | int used, ignored; | 1069 | int used, ignored; | |
1070 | 1070 | |||
1071 | if (def == NULL) | 1071 | if (def == NULL) | |
1072 | /* don't know whether or not the functions returns a value */ | 1072 | /* don't know whether or not the functions returns a value */ | |
1073 | return; | 1073 | return; | |
1074 | 1074 | |||
1075 | if (hte->h_calls == NULL) | 1075 | if (hte->h_calls == NULL) | |
1076 | return; | 1076 | return; | |
1077 | 1077 | |||
1078 | if (def->s_rval) { | 1078 | if (def->s_rval) { | |
1079 | /* | 1079 | /* | |
1080 | * XXX as soon as we are able to disable single warnings | 1080 | * XXX as soon as we are able to disable single warnings | |
1081 | * the following dependencies from hflag should be removed. | 1081 | * the following dependencies from hflag should be removed. | |
1082 | * but for now I do'nt want to be botherd by this warnings | 1082 | * but for now I don't want to be bothered by this warnings | |
1083 | * which are almost always useless. | 1083 | * which are almost always useless. | |
1084 | */ | 1084 | */ | |
1085 | if (hflag == 0) | 1085 | if (hflag == 0) | |
1086 | return; | 1086 | return; | |
1087 | if (hflag == 1 && bsearch(hte->h_name, ignorelist, | 1087 | if (hflag == 1 && bsearch(hte->h_name, ignorelist, | |
1088 | __arraycount(ignorelist), sizeof(ignorelist[0]), | 1088 | __arraycount(ignorelist), sizeof(ignorelist[0]), | |
1089 | (int (*)(const void *, const void *))strcmp) != NULL) | 1089 | (int (*)(const void *, const void *))strcmp) != NULL) | |
1090 | return; | 1090 | return; | |
1091 | 1091 | |||
1092 | /* function has return value */ | 1092 | /* function has return value */ | |
1093 | used = ignored = 0; | 1093 | used = ignored = 0; | |
1094 | for (call = hte->h_calls; call != NULL; call = call->f_next) { | 1094 | for (call = hte->h_calls; call != NULL; call = call->f_next) { | |
1095 | used |= call->f_rused || call->f_rdisc; | 1095 | used |= call->f_rused || call->f_rdisc; |
--- src/usr.bin/xlint/lint2/main2.c 2016/09/05 00:40:30 1.9
+++ src/usr.bin/xlint/lint2/main2.c 2021/01/04 22:26:51 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: main2.c,v 1.9 2016/09/05 00:40:30 sevan Exp $ */ | 1 | /* $NetBSD: main2.c,v 1.10 2021/01/04 22:26:51 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) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: main2.c,v 1.9 2016/09/05 00:40:30 sevan Exp $"); | 40 | __RCSID("$NetBSD: main2.c,v 1.10 2021/01/04 22:26:51 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <stdio.h> | 43 | #include <stdio.h> | |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> | |
45 | #include <string.h> | 45 | #include <string.h> | |
46 | #include <unistd.h> | 46 | #include <unistd.h> | |
47 | 47 | |||
48 | #include "lint2.h" | 48 | #include "lint2.h" | |
49 | 49 | |||
50 | /* warnings for symbols which are declared but not defined or used */ | 50 | /* warnings for symbols which are declared but not defined or used */ | |
51 | int xflag; | 51 | int xflag; | |
52 | 52 | |||
53 | /* | 53 | /* | |
@@ -62,27 +62,27 @@ const char *libname; | @@ -62,27 +62,27 @@ const char *libname; | |||
62 | 62 | |||
63 | int pflag; | 63 | int pflag; | |
64 | 64 | |||
65 | /* | 65 | /* | |
66 | * warnings for (tentative) definitions of the same name in more than | 66 | * warnings for (tentative) definitions of the same name in more than | |
67 | * one translation unit | 67 | * one translation unit | |
68 | */ | 68 | */ | |
69 | int sflag; | 69 | int sflag; | |
70 | 70 | |||
71 | int tflag; | 71 | int tflag; | |
72 | 72 | |||
73 | /* | 73 | /* | |
74 | * If a complaint stems from a included file, print the name of the included | 74 | * If a complaint stems from a included file, print the name of the included | |
75 | * file instead of the name spezified at the command line followed by '?' | 75 | * file instead of the name specified at the command line followed by '?' | |
76 | */ | 76 | */ | |
77 | int Hflag; | 77 | int Hflag; | |
78 | 78 | |||
79 | int hflag; | 79 | int hflag; | |
80 | 80 | |||
81 | /* Print full path names, not only the last component */ | 81 | /* Print full path names, not only the last component */ | |
82 | int Fflag; | 82 | int Fflag; | |
83 | 83 | |||
84 | /* | 84 | /* | |
85 | * List of libraries (from -l flag). These libraries are read after all | 85 | * List of libraries (from -l flag). These libraries are read after all | |
86 | * other input files has been read and, for Cflag, after the new lint library | 86 | * other input files has been read and, for Cflag, after the new lint library | |
87 | * has been written. | 87 | * has been written. | |
88 | */ | 88 | */ |
--- src/usr.bin/xlint/lint2/read.c 2021/01/01 11:51:15 1.35
+++ src/usr.bin/xlint/lint2/read.c 2021/01/04 22:26:51 1.36
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: read.c,v 1.35 2021/01/01 11:51:15 rillig Exp $ */ | 1 | /* $NetBSD: read.c,v 1.36 2021/01/04 22:26:51 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,76 +28,76 @@ | @@ -28,76 +28,76 @@ | |||
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) && !defined(lint) | 40 | #if defined(__RCSID) && !defined(lint) | |
41 | __RCSID("$NetBSD: read.c,v 1.35 2021/01/01 11:51:15 rillig Exp $"); | 41 | __RCSID("$NetBSD: read.c,v 1.36 2021/01/04 22:26:51 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 */ | |
55 | static int srcfile; | 55 | static int srcfile; | |
56 | 56 | |||
57 | /* | 57 | /* | |
58 | * The array pointed to by inpfns maps the file name indices of input files | 58 | * The array pointed to by inpfns maps the file name indices of input files | |
59 | * to the file name indices used in lint2 | 59 | * to the file name indices used in lint2 | |
60 | */ | 60 | */ | |
61 | static short *inpfns; | 61 | static short *inpfns; | |
62 | static size_t ninpfns; | 62 | static size_t ninpfns; | |
63 | 63 | |||
64 | /* | 64 | /* | |
65 | * The array pointed to by *fnames maps file name indizes to file names. | 65 | * The array pointed to by *fnames maps file name indices to file names. | |
66 | * Indices of type short are used instead of pointers to save memory. | 66 | * Indices of type short are used instead of pointers to save memory. | |
67 | */ | 67 | */ | |
68 | const char **fnames; | 68 | const char **fnames; | |
69 | static size_t *flines; | 69 | static size_t *flines; | |
70 | static size_t nfnames; | 70 | static size_t nfnames; | |
71 | 71 | |||
72 | /* | 72 | /* | |
73 | * Types are shared (to save memory for the types itself) and accessed | 73 | * Types are shared (to save memory for the types itself) and accessed | |
74 | * via indices (to save memory for references to types (indices are short)). | 74 | * via indices (to save memory for references to types (indices are short)). | |
75 | * To share types, a equal type must be located fast. This is done by a | 75 | * To share types, a equal type must be located fast. This is done by a | |
76 | * hash table. Access by indices is done via an array of pointers to the | 76 | * hash table. Access by indices is done via an array of pointers to the | |
77 | * types. | 77 | * types. | |
78 | */ | 78 | */ | |
79 | typedef struct thtab { | 79 | typedef struct thtab { | |
80 | const char *th_name; | 80 | const char *th_name; | |
81 | u_short th_idx; | 81 | u_short th_idx; | |
82 | struct thtab *th_next; | 82 | struct thtab *th_next; | |
83 | } thtab_t; | 83 | } thtab_t; | |
84 | static thtab_t **thtab; /* hash table */ | 84 | static thtab_t **thtab; /* hash table */ | |
85 | type_t **tlst; /* array for indexed access */ | 85 | type_t **tlst; /* array for indexed access */ | |
86 | static size_t tlstlen; /* length of tlst */ | 86 | static size_t tlstlen; /* length of tlst */ | |
87 | 87 | |||
88 | static hte_t **renametab; | 88 | static hte_t **renametab; | |
89 | 89 | |||
90 | /* index of current C source file (as spezified at the command line) */ | 90 | /* index of current C source file (as specified at the command line) */ | |
91 | static int csrcfile; | 91 | static int csrcfile; | |
92 | 92 | |||
93 | 93 | |||
94 | #define inperr(fmt, args...) \ | 94 | #define inperr(fmt, args...) \ | |
95 | inperror(__FILE__, __LINE__, fmt, ##args) | 95 | inperror(__FILE__, __LINE__, fmt, ##args) | |
96 | static void inperror(const char *, size_t, const char *, ...); | 96 | static void inperror(const char *, size_t, const char *, ...); | |
97 | static void setsrc(const char *); | 97 | static void setsrc(const char *); | |
98 | static void setfnid(int, const char *); | 98 | static void setfnid(int, const char *); | |
99 | static void funccall(pos_t *, const char *); | 99 | static void funccall(pos_t *, const char *); | |
100 | static void decldef(pos_t *, const char *); | 100 | static void decldef(pos_t *, const char *); | |
101 | static void usedsym(pos_t *, const char *); | 101 | static void usedsym(pos_t *, const char *); | |
102 | static u_short inptype(const char *, const char **); | 102 | static u_short inptype(const char *, const char **); | |
103 | static int gettlen(const char *, const char **); | 103 | static int gettlen(const char *, const char **); | |
@@ -488,48 +488,48 @@ decldef(pos_t *posp, const char *cp) | @@ -488,48 +488,48 @@ decldef(pos_t *posp, const char *cp) | |||
488 | */ | 488 | */ | |
489 | for (symp = hte->h_syms; symp != NULL; symp = symp->s_next) { | 489 | for (symp = hte->h_syms; symp != NULL; symp = symp->s_next) { | |
490 | if (symp->s_pos.p_isrc == sym.s_pos.p_isrc && | 490 | if (symp->s_pos.p_isrc == sym.s_pos.p_isrc && | |
491 | symp->s_pos.p_iline == sym.s_pos.p_iline && | 491 | symp->s_pos.p_iline == sym.s_pos.p_iline && | |
492 | symp->s_type == sym.s_type && | 492 | symp->s_type == sym.s_type && | |
493 | ((symp->s_def == DECL && sym.s_def == DECL) || | 493 | ((symp->s_def == DECL && sym.s_def == DECL) || | |
494 | (!sflag && symp->s_def == TDEF && sym.s_def == TDEF)) && | 494 | (!sflag && symp->s_def == TDEF && sym.s_def == TDEF)) && | |
495 | !symp->s_static && !sym.s_static) { | 495 | !symp->s_static && !sym.s_static) { | |
496 | break; | 496 | break; | |
497 | } | 497 | } | |
498 | } | 498 | } | |
499 | 499 | |||
500 | if (symp == NULL) { | 500 | if (symp == NULL) { | |
501 | /* allocsym reserviert keinen Platz fuer s_nva */ | 501 | /* allocsym does not reserve space for s_nva */ | |
502 | if (sym.s_va || sym.s_prfl || sym.s_scfl) { | 502 | if (sym.s_va || sym.s_prfl || sym.s_scfl) { | |
503 | symp = xalloc(sizeof (sym_t)); | 503 | symp = xalloc(sizeof (sym_t)); | |
504 | *symp = sym; | 504 | *symp = sym; | |
505 | } else { | 505 | } else { | |
506 | symp = xalloc(sizeof (symp->s_s)); | 506 | symp = xalloc(sizeof (symp->s_s)); | |
507 | symp->s_s = sym.s_s; | 507 | symp->s_s = sym.s_s; | |
508 | } | 508 | } | |
509 | *hte->h_lsym = symp; | 509 | *hte->h_lsym = symp; | |
510 | hte->h_lsym = &symp->s_next; | 510 | hte->h_lsym = &symp->s_next; | |
511 | 511 | |||
512 | /* XXX hack so we can remember where a symbol was renamed */ | 512 | /* XXX hack so we can remember where a symbol was renamed */ | |
513 | if (renamed) | 513 | if (renamed) | |
514 | renamehte->h_syms = symp; | 514 | renamehte->h_syms = symp; | |
515 | } | 515 | } | |
516 | 516 | |||
517 | if (*cp != '\0') | 517 | if (*cp != '\0') | |
518 | inperr("trailing line: %s", cp); | 518 | inperr("trailing line: %s", cp); | |
519 | } | 519 | } | |
520 | 520 | |||
521 | /* | 521 | /* | |
522 | * Read an u-record (emited by lint1 if a symbol was used). | 522 | * Read an u-record (emitted by lint1 if a symbol was used). | |
523 | */ | 523 | */ | |
524 | static void | 524 | static void | |
525 | usedsym(pos_t *posp, const char *cp) | 525 | usedsym(pos_t *posp, const char *cp) | |
526 | { | 526 | { | |
527 | usym_t *usym; | 527 | usym_t *usym; | |
528 | hte_t *hte; | 528 | hte_t *hte; | |
529 | const char *name; | 529 | const char *name; | |
530 | 530 | |||
531 | usym = xalloc(sizeof (usym_t)); | 531 | usym = xalloc(sizeof (usym_t)); | |
532 | usym->u_pos = *posp; | 532 | usym->u_pos = *posp; | |
533 | 533 | |||
534 | /* needed as delimiter between two numbers */ | 534 | /* needed as delimiter between two numbers */ | |
535 | if (*cp++ != 'x') | 535 | if (*cp++ != 'x') |
--- src/usr.bin/xlint/xlint/xlint.c 2020/12/29 11:35:11 1.51
+++ src/usr.bin/xlint/xlint/xlint.c 2021/01/04 22:26:51 1.52
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: xlint.c,v 1.51 2020/12/29 11:35:11 rillig Exp $ */ | 1 | /* $NetBSD: xlint.c,v 1.52 2021/01/04 22:26:51 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) && !defined(lint) | 40 | #if defined(__RCSID) && !defined(lint) | |
41 | __RCSID("$NetBSD: xlint.c,v 1.51 2020/12/29 11:35:11 rillig Exp $"); | 41 | __RCSID("$NetBSD: xlint.c,v 1.52 2021/01/04 22:26:51 rillig Exp $"); | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/wait.h> | 45 | #include <sys/wait.h> | |
46 | #include <sys/stat.h> | 46 | #include <sys/stat.h> | |
47 | #include <sys/utsname.h> | 47 | #include <sys/utsname.h> | |
48 | #include <errno.h> | 48 | #include <errno.h> | |
49 | #include <fcntl.h> | 49 | #include <fcntl.h> | |
50 | #include <paths.h> | 50 | #include <paths.h> | |
51 | #include <signal.h> | 51 | #include <signal.h> | |
52 | #include <stdio.h> | 52 | #include <stdio.h> | |
53 | #include <stdlib.h> | 53 | #include <stdlib.h> | |
54 | #include <string.h> | 54 | #include <string.h> | |
@@ -72,27 +72,27 @@ static int cppoutfd = -1; | @@ -72,27 +72,27 @@ static int cppoutfd = -1; | |||
72 | 72 | |||
73 | /* files created by 1st pass */ | 73 | /* files created by 1st pass */ | |
74 | static char **p1out; | 74 | static char **p1out; | |
75 | 75 | |||
76 | /* input files for 2nd pass (without libraries) */ | 76 | /* input files for 2nd pass (without libraries) */ | |
77 | static char **p2in; | 77 | static char **p2in; | |
78 | 78 | |||
79 | /* library which will be created by 2nd pass */ | 79 | /* library which will be created by 2nd pass */ | |
80 | static char *p2out; | 80 | static char *p2out; | |
81 | 81 | |||
82 | /* flags always passed to cc(1) */ | 82 | /* flags always passed to cc(1) */ | |
83 | static char **cflags; | 83 | static char **cflags; | |
84 | 84 | |||
85 | /* flags for cc(1), controled by sflag/tflag */ | 85 | /* flags for cc(1), controlled by sflag/tflag */ | |
86 | static char **lcflags; | 86 | static char **lcflags; | |
87 | 87 | |||
88 | /* flags for lint1 */ | 88 | /* flags for lint1 */ | |
89 | static char **l1flags; | 89 | static char **l1flags; | |
90 | 90 | |||
91 | /* flags for lint2 */ | 91 | /* flags for lint2 */ | |
92 | static char **l2flags; | 92 | static char **l2flags; | |
93 | 93 | |||
94 | /* libraries for lint2 */ | 94 | /* libraries for lint2 */ | |
95 | static char **l2libs; | 95 | static char **l2libs; | |
96 | 96 | |||
97 | /* default libraries */ | 97 | /* default libraries */ | |
98 | static char **deflibs; | 98 | static char **deflibs; |