Home | History | Annotate | only in /src/usr.bin/xlint/lint2
History log of /src/usr.bin/xlint/lint2
RevisionDateAuthorComments
 1.24 12-May-2024  rillig lint: remove redundant LINTFLAGS for lint2

The -T flag is already provided by ../Makefile.inc, along with several
other flags.
 1.23 13-Jan-2023  rillig lint: move xalloc to the only file where it is used

No functional change.
 1.22 22-Aug-2021  rillig lint: only include code in the binaries that is actually used

No functional change.
 1.21 08-Aug-2021  rillig lint: force strict bool mode

No functional change.
 1.20 18-Apr-2021  rillig lint: remove WARNS=3, falling back to the default WARNS=5

It's strange that GCC does not warn about the nonliteral format strings
in lint1/err.c, lint2/msg.c and lint2/read.c, despite -Wformat=2, but
Clang does.
 1.19 10-Apr-2021  rillig lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.
 1.18 16-Jan-2021  rillig lint: fix LINTFLAGS for lint2

These have never worked since they report a syntax error in
<sys/cdefs.h> just because there is an __inline over there.

I wonder why it has been necessary at all to have custom LINTFLAGS for
lint itself. It's just an ordinary program.
 1.17 08-Oct-2006  peter WFORMAT is no more...
 1.16 07-Apr-2005  christos Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.
 1.15 18-May-2003  lukem Now that <bsd.prog.mk> DTRT if HOSTPROG is defined (i.e, it is a no-op),
there's no need to special-case .include-ing it.
 1.14 18-Sep-2002  lukem makefile delint. use NETBSDSRCDIR as appropriate
 1.13 18-Jan-2002  thorpej Centralize the initialization/declaration of the ttab.
 1.12 18-Jan-2002  thorpej * Move stuff shared between lint1 and lint2 to the new common/ directory.
* Move the arch/ directory out of lint1/ into the top-level.
 1.11 12-Dec-2001  tv MKfoo=no -> NOfoo
 1.10 12-Nov-2001  tv Major overhaul of src/tools and host toolchain. Summary of changes:

* Rewrite src/tools Make logic to work like the rest of the tree wrt
"dependall" and "install". The old "make build" hack is gone.

* Remove the MKTOOLS logic. This was linked to the "make build" hack,
and was only needed because TOOLDIR originally had no writable default.

* Redo the GNU configure/make logic to make it fit reasonably in a
BSD make wrapper. Use new ${.ALLTARGETS} variable to scan for
targets in $(srcdir), and mark them with .MADE: to prevent rebuilding.

* Only build cross tools in src/tools; remove some messy logic in
src/usr.* and src/gnu/usr.* that would do target filename rewriting
(improves consistency and readability).

* Add the ability to build cross gdb at tool build time by setting
MKCROSSGDB (default no) to "yes" in mk.conf.

* Add src/tools/groff and set up paths to work with this cross groff.
 1.9 24-Oct-2001  thorpej Add support for putting prefixes on the name of lint(1)'s front
and back ends. This means that it can be built as a cross tool.
Part of the fix for bin/14280.
 1.8 14-Aug-2001  tv Add hooks to allow toolchain bits to be reachover-built at the top level.
 1.7 11-Oct-2000  is More format string cleanup by sommerfeld.
 1.6 13-Feb-1999  lukem branches: 1.6.2; 1.6.10;
convert from NOxxx= to MKxxx=no.
include <bsd.own.mk> if testing a MKxxx variable.
 1.5 24-Oct-1997  lukem use CPPFLAGS instead of CFLAGS
 1.4 08-May-1997  gwr branches: 1.4.2;
Back out the .PATH.c changes. The .depend problem (and others)
will be fixed using the new .NOPATH make feature instead.
 1.3 06-May-1997  gwr Use .PATH.c: ...
 1.2 03-Jul-1995  cgd RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.4.2.1 04-Nov-1997  thorpej Pull up from trunk: make renaming work and other minor fixes.
 1.6.10.1 18-Oct-2000  tv Pullup usr.bin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.6.2.1 19-Oct-2000  he Pull up revision 1.7 (requested by he):
Format string cleanup.
 1.3 30-Nov-2024  rillig lint: reword lint2 warnings, reduce punctuation

The previous diagnostics used unusual punctuation, for example by placing
spaces inside parentheses, as well as using space-space-tab and
double-colon as separators. Convert these diagnostics into readily
readable prose, and mark them clearly as coming from lint2, so that they
can be related to the tests in /usr/tests/usr.bin/xlint/lint2/msg_???.ln.

This change means that usr.bin/error no longer recognizes these messages
as coming from lint2, but that can be fixed later if necessary.
 1.2 10-Sep-2021  rillig branches: 1.2.4;
tests/lint: align message checker for lint2 to the one from lint1

No functional change.
 1.1 28-Feb-2021  rillig lint2: add redundancy checker for comments in source code

Based on the redundancy checker for lint1.

No functional change.
 1.2.4.1 02-Aug-2025  perseant Sync with HEAD
 1.72 24-May-2025  rillig lint: constify
 1.71 24-May-2025  rillig lint: fix wording in a warning about a type conflict

An object does not have a return type, only functions do.
 1.70 10-Apr-2025  rillig lint: remove now-unnecessary CONSTCOND comments
 1.69 27-Feb-2025  rillig lint: normalize whitespace
 1.68 30-Nov-2024  rillig lint: reword lint2 warnings, reduce punctuation

The previous diagnostics used unusual punctuation, for example by placing
spaces inside parentheses, as well as using space-space-tab and
double-colon as separators. Convert these diagnostics into readily
readable prose, and mark them clearly as coming from lint2, so that they
can be related to the tests in /usr/tests/usr.bin/xlint/lint2/msg_???.ln.

This change means that usr.bin/error no longer recognizes these messages
as coming from lint2, but that can be fixed later if necessary.
 1.67 12-May-2024  rillig branches: 1.67.2;
lint: add wrapper for <ctype.h> functions, for strict bool mode

When using the Clang preprocessor (with MKLLVM=yes), the preprocessor
output does not indicate which tokens come from a system header and
which tokens come from the user code. Lint's strict bool mode relies on
this information to treat the character classification functions from
<ctype.h> as if their return type were bool instead of int.

These wrapper functions are only used when their argument is indeed a
'char', but not when the argument might be 'EOF or representable as an
unsigned char', such as when reading a byte from the input.
 1.66 02-Mar-2024  rillig lint: remove custom wrappers around <ctype.h> functions
 1.65 03-Dec-2023  rillig lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.64 03-Dec-2023  rillig lint: re-wrap comments

No functional change.
 1.63 03-Dec-2023  rillig lint: indent statement continuations consistently

No binary change.
 1.62 02-Dec-2023  rillig lint: remove redundant empty lines

No functional change.
 1.61 26-Aug-2023  rillig lint: make diagnostics about ANSI C more international
 1.60 13-Jul-2023  rillig lint: indent copyright lines consistently
 1.59 10-Jul-2023  rillig lint: push memory management one layer down

Just as with type_name in lint1, it is more convenient if the
application code does not have to deal with memory management.
 1.58 10-Jul-2023  rillig lint: clean up lint2
 1.57 03-Jul-2023  rillig lint: invert the -u, -v and -z flags

Now they behave the same as in the manual page.

No functional change.
 1.56 03-Jul-2023  rillig lint: rename uppercase QUAD to LLONG

No binary change.
 1.55 09-Jun-2023  rillig lint: indent local variables consistently

No binary change.
 1.54 22-May-2023  rillig lint: rename constant NOTSPEC to NO_TSPEC

It was too easy to misread the old name as NOT_SPEC instead of the
intended NO_TSPEC.
 1.53 14-Jan-2023  rillig lint: rename lint2 functions to be more expressive
 1.52 01-Oct-2022  rillig lint: add hyphen to adjective 'old-style'
 1.51 28-Aug-2022  rillig lint: clean up visual clutter

No functional change.
 1.50 28-Aug-2022  rillig lint: rename functions to be clearer

No need anymore to keep external identifiers at the "6 significant
initial characters" mandated by C90.
 1.49 30-May-2022  rillig lint: clean up comments

No binary change.
 1.48 20-May-2022  rillig lint: use __RCSID in lint mode as well

Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
 1.47 21-Apr-2022  rillig lint: expand the last remaining __arraycount

For consistency with the other expressions for an array length, which
already use the expanded form.

No functional change.
 1.46 16-Nov-2021  rillig lint: clean up lint2

No functional change.
 1.45 29-Aug-2021  rillig lint: un-abbreviate members of sym_t

No functional change.
 1.44 22-Aug-2021  rillig lint: constify lint2 checking functions

No functional change.
 1.43 08-Aug-2021  rillig lint: force strict bool mode

No functional change.
 1.42 02-Apr-2021  rillig lint: add parentheses after sizeof, as required by share/misc/style

No functional change.
 1.41 26-Mar-2021  rillig lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'

No functional change.
 1.40 28-Feb-2021  rillig lint2: align comments in the code with actual messages
 1.39 22-Feb-2021  rillig lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.
 1.38 19-Feb-2021  rillig lint: rename t_isenum and t_aincompl to be more expressive

No functional change.
 1.37 24-Jan-2021  rillig lint: update data types in comments from int to bool
 1.36 18-Jan-2021  rillig lint: clean up code (mostly comments)
 1.35 16-Jan-2021  rillig lint: replace integer constant expressions with true and false

LINTFLAGS=-gST make lint, with manual review.

The error messages from lint are all correct, they are not complete
though. The return value of a function returning bool may still be
compared to the integer 0.
 1.34 16-Jan-2021  rillig lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once. See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode. The only missing thing was using the constant
literals false and true instead of 0 and 1. For sure there are some
integer literals left that can be converted. For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.
 1.33 10-Jan-2021  rillig lint: rename type classification macros

The previous names tspec_is_int and tspec_is_uint were confusing because
there are actually tspec_t constants called INT and UINT, these
classification macros return true for other integer types as well,
though.

While here, remove the prefix "tspec_" from these macros. It wasn't as
helpful as intended, in many cases it was obviously redundant, when it
was called as tspec_is_integer(tn->tn_type->t_tspec).

No functional change.
 1.32 04-Jan-2021  rillig lint: fix typos and other minor stylistic issues
 1.31 02-Jan-2021  rillig lint: fix buffer truncation for type names

Previously, most type names had been cut off after 63 significant
characters. In some cases, 127 characters survived, or 255. And for
the debugging messages, sometimes even 1023. This inconsistency was
useless.

It was wrong in the first place to make the caller of the function
tyname responsible for handling the buffer. That's not something a
caller of such a simple function should do. These callers have better
things to do.

The API of the new function type_name is as simple as possible.

In the implementation, the name of the type is generated anew each time.
I just didn't know whether the type details could change, once the type
is initialized, and I didn't want to find out. To be on the safe side,
the resulting type name is cached, independently of the type it was
generated for. Using a trivial, unbalanced binary tree should be good
enough for now.

All this work is necessary to support adding new debug logging, without
being distracted by irrelevant implementation details such as these
buffer sizes. Adding new debug messages should be fun and easy; up to
now, it was overly bureaucratic.
 1.30 01-Jan-2021  rillig lint: rename styp and utyp
 1.29 30-Dec-2020  rillig lint: rename more _nxt members to _next
 1.28 30-Dec-2020  rillig lint: rename s_nxt to s_next
 1.27 29-Dec-2020  rillig lint: remove redundant parentheses around return value
 1.26 28-Dec-2020  rillig lint: remove trailing whitespace
 1.25 28-Dec-2020  rillig lint: sort includes
 1.24 28-Dec-2020  rillig lint: rename tspec macros
 1.23 26-Dec-2017  christos Don't print duplicate definitions for inline symbols.
 1.22 17-Oct-2011  mbalmer Fix typo in comment.
 1.21 14-Jan-2010  christos Add a list of functions where we usually don't care about their return
code. Can be bypassed by -hh
 1.20 14-Apr-2009  lukem Fix -Wshadow issues
 1.19 26-Apr-2008  christos branches: 1.19.8;
print the types involved in the mismatch.
 1.18 07-Apr-2005  christos branches: 1.18.20;
Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.
 1.17 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.16 31-Jan-2002  tv branches: 1.16.4;
Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.15 21-Jan-2002  tv Add hooks for compiling on non-NetBSD hosts.
 1.14 18-Jan-2002  thorpej Centralize the initialization/declaration of the ttab.
 1.13 18-Jan-2002  thorpej Initialize the type table with the correct type sizes for the target.
 1.12 21-Nov-2001  wiz "than" instead of "then".
 1.11 26-Jul-2001  wiz Various typos in comments (neccessary, sceme, choise, ...).
 1.10 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.9 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.8 28-Jul-1998  mycroft branches: 1.8.8;
If the return value is sometimes discarded, output `sometimes ignored' rather
than `always ignored'.
 1.7 27-Jul-1998  mycroft Fix a recurring typo: comparision -> comparison.
 1.6 27-Jul-1998  mycroft Fix uses of uninitialized memory, and incorrect types for initializers.
From ITOH Yasufumi, PR 5861.
 1.5 22-Feb-1998  christos WARNSify
 1.4 03-Nov-1997  cgd in chkdnud(), don't warn if the defined-but-not-used object is a function.
chkdnud() is used (only) to implement the -x option, which is supposed to
warn for variables only.
 1.3 22-Dec-1996  cgd branches: 1.3.2;
* Ignore the size of integer arguments when trying to automatically
convert them to pointers. If they're zero, they're converted (to
NULL pointers) regardless of size. If they're non-zero, they can't
be converted (without a cast). This matches the behavior of other
version of lint, e.g. the lints on Digital UNIX and HP-UX.

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.
 1.2 03-Jul-1995  cgd RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.3.2.1 04-Nov-1997  thorpej Pull up from trunk: make renaming work and other minor fixes.
 1.8.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.16.4.1 22-Jun-2004  tron Pull up revision 1.17 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.18.20.1 18-May-2008  yamt sync with head.
 1.19.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.67.2.1 02-Aug-2025  perseant Sync with HEAD
 1.42 24-May-2025  rillig lint: constify
 1.41 16-May-2025  rillig lint: clean up
 1.40 29-Aug-2024  rillig lint: support GCC's __auto_type

Fixes PR toolchain/58654.
 1.39 12-May-2024  rillig branches: 1.39.2;
lint: add wrapper for <ctype.h> functions, for strict bool mode

When using the Clang preprocessor (with MKLLVM=yes), the preprocessor
output does not indicate which tokens come from a system header and
which tokens come from the user code. Lint's strict bool mode relies on
this information to treat the character classification functions from
<ctype.h> as if their return type were bool instead of int.

These wrapper functions are only used when their argument is indeed a
'char', but not when the argument might be 'EOF or representable as an
unsigned char', such as when reading a byte from the input.
 1.38 02-Mar-2024  rillig lint: remove custom wrappers around <ctype.h> functions
 1.37 03-Dec-2023  rillig lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.36 12-Aug-2023  rillig lint: clean up comments

There's no output buffer anymore.
 1.35 12-Aug-2023  rillig lint: remove redundant comments
 1.34 12-Aug-2023  rillig lint: for each record in the output file, write the newline immediately

There's no point delaying the '\n' until the next line is written.
 1.33 13-Jul-2023  rillig lint: indent copyright lines consistently
 1.32 29-Jun-2023  rillig lint: clean up initialization of type properties

No functional change.
 1.31 09-Jun-2023  rillig lint: indent local variables consistently

No binary change.
 1.30 02-Feb-2023  rillig lint: clean up

In symtab_search, most of the conditions were redundant, so remove them.

In read_byte, using CHAR_MASK was conceptually wrong, as that constant
is from the target platform while the lexical analysis happens on the
host platform. It was unnecessary as well, as a hypothetical host
platform with 36-bit chars might encode the characters from the basic
source character set as numbers higher than 0x0_0000_00ff. Since lint
assumes that both the source character set as well as the execution
character set are the same and based on 8-bit bytes, nothing changes.

No functional change.
 1.29 14-Jan-2023  rillig lint: clean up messages for internal errors
 1.28 20-May-2022  rillig lint: use __RCSID in lint mode as well

Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
 1.27 16-Nov-2021  rillig lint: clean up lint2

No functional change.
 1.26 04-Sep-2021  rillig lint: inline local variables in outtype

No functional change.
 1.25 04-Sep-2021  rillig lint: condense code for writing to a lint library

Same as in lint1.

No functional change.
 1.24 04-Sep-2021  rillig lint: use 'char' as type for passing characters to functions

No functional change.
 1.23 29-Aug-2021  rillig lint: un-abbreviate members of sym_t

No functional change.
 1.22 28-Aug-2021  rillig lint: write the entries for the libraries in alphabetical order

This makes them easier to read by humans.

The checks are still performed in hashcode order since there are no
tests that would cover this change.
 1.21 28-Aug-2021  rillig lint: remove unused parameter from forall

No functional change.
 1.20 24-Aug-2021  rillig lint: allow libraries to use 128-bit integer types
 1.19 02-Apr-2021  rillig lint: add parentheses after sizeof, as required by share/misc/style

No functional change.
 1.18 26-Mar-2021  rillig lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'

No functional change.
 1.17 22-Feb-2021  rillig lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.
 1.16 19-Feb-2021  rillig lint: rename t_isenum and t_aincompl to be more expressive

No functional change.
 1.15 30-Dec-2020  rillig lint: rename s_nxt to s_next
 1.14 29-Dec-2020  rillig lint: remove redundant parentheses around return value
 1.13 26-Sep-2008  matt Teach lint about long double _Complex (C99)
 1.12 26-Apr-2008  christos same change: double is emitted as '\0'
 1.11 25-Apr-2008  christos handle lintlibrary output of _Complex types.
 1.10 12-Sep-2004  yamt branches: 1.10.26;
recognize _Bool.
 1.9 31-Jan-2002  tv Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.8 21-Jan-2002  tv Add hooks for compiling on non-NetBSD hosts.
 1.7 26-Jul-2001  wiz Various typos in comments (neccessary, sceme, choise, ...).
 1.6 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.5 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.4 22-Feb-1998  christos branches: 1.4.8;
WARNSify
 1.3 22-Dec-1996  cgd * recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.
 1.2 03-Jul-1995  cgd RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.4.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.10.26.1 18-May-2008  yamt sync with head.
 1.39.2.1 02-Aug-2025  perseant Sync with HEAD
 1.24 24-May-2025  rillig lint: constify
 1.23 31-Aug-2024  rillig lint: KNF
 1.22 03-Dec-2023  rillig branches: 1.22.2;
lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.21 13-Jul-2023  rillig lint: indent copyright lines consistently
 1.20 10-Jul-2023  rillig lint: clean up lint2
 1.19 14-Jan-2023  rillig lint: rename lint2 functions to be more expressive
 1.18 13-Jan-2023  rillig lint: move xalloc to the only file where it is used

No functional change.
 1.17 13-Jan-2023  rillig lint: remove custom memory allocator

Besides adding complexity, the custom memory allocator didn't invalidate
freed memory, which made it harder to find possible use-after-free bugs.
 1.16 16-Nov-2021  rillig lint: clean up initialization of lint2 symbol table

No functional change.
 1.15 05-Sep-2021  rillig lint: hide irrelevant type information from lint2

No functional change.
 1.14 28-Aug-2021  rillig lint: write the entries for the libraries in alphabetical order

This makes them easier to read by humans.

The checks are still performed in hashcode order since there are no
tests that would cover this change.
 1.13 28-Aug-2021  rillig lint: remove unused parameter from forall

No functional change.
 1.12 22-Aug-2021  rillig lint: remove Tflag and pflag from common declarations

These flags are only needed by lint1 and lint2, but not by the driver
xlint.

No functional change.
 1.11 22-Aug-2021  rillig lint: constify lint2 checking functions

No functional change.
 1.10 10-Aug-2021  rillig lint: clean up comments
 1.9 16-Jan-2021  rillig lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once. See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode. The only missing thing was using the constant
literals false and true instead of 0 and 1. For sure there are some
integer literals left that can be converted. For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.
 1.8 18-Jan-2002  thorpej Centralize the initialization/declaration of the ttab.
 1.7 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.6 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.5 22-Feb-1998  christos branches: 1.5.8;
WARNSify
 1.4 03-Nov-1997  cgd implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.
 1.3 22-Dec-1996  cgd branches: 1.3.2;
* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.
 1.2 03-Jul-1995  cgd RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.3.2.1 04-Nov-1997  thorpej Pull up from trunk: make renaming work and other minor fixes.
 1.5.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.22.2.1 02-Aug-2025  perseant Sync with HEAD
 1.30 24-May-2025  rillig lint: constify
 1.29 03-Dec-2023  rillig branches: 1.29.2;
lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.28 13-Jul-2023  rillig lint: indent copyright lines consistently
 1.27 10-Jul-2023  rillig lint: clean up lint2
 1.26 10-Jul-2023  rillig lint: clean up wchar_t and hash tables
 1.25 09-Jun-2023  rillig lint: indent local variables consistently

No binary change.
 1.24 20-May-2022  rillig lint: use __RCSID in lint mode as well

Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
 1.23 16-Nov-2021  rillig lint: clean up initialization of lint2 symbol table

No functional change.
 1.22 28-Aug-2021  rillig lint: clean up hash functions

No functional change.
 1.21 28-Aug-2021  rillig lint: fold constants in hash functions

All platforms supported by lint have sizeof(unsigned int) == 4 and
CHAR_BIT == 8. There is no need to encode these expressions in a hash
function, they only made the code harder to read.

No functional change.
 1.20 28-Aug-2021  rillig lint: fix memory leak in symtab_forall_sorted (since today)
 1.19 28-Aug-2021  rillig lint: write the entries for the libraries in alphabetical order

This makes them easier to read by humans.

The checks are still performed in hashcode order since there are no
tests that would cover this change.
 1.18 28-Aug-2021  rillig lint: remove unused parameter from forall

No functional change.
 1.17 28-Aug-2021  rillig lint: un-abbreviate unsigned integer types

No functional change.
 1.16 22-Aug-2021  rillig lint: use unsigned integers for storing hash values

The computation of the hash values is unchanged, only the resulting
value (which is always less than 1009 anyway, see HSHSIZ2) is stored as
unsigned as well.

No functional change.
 1.15 02-Apr-2021  rillig lint: add parentheses after sizeof, as required by share/misc/style

No functional change.
 1.14 26-Mar-2021  rillig lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'

No functional change.
 1.13 16-Jan-2021  rillig lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once. See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode. The only missing thing was using the constant
literals false and true instead of 0 and 1. For sure there are some
integer literals left that can be converted. For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.
 1.12 29-Dec-2020  rillig lint: remove redundant parentheses around return value
 1.11 15-Apr-2009  christos Lukemify (WARNS=4)
 1.10 14-Apr-2009  lukem Fix -Wcast-qual issue
 1.9 20-Jun-2004  jmc branches: 1.9.36;
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.8 31-Jan-2002  tv branches: 1.8.4;
Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.7 21-Jan-2002  tv Add hooks for compiling on non-NetBSD hosts.
 1.6 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.5 27-Jul-1998  mycroft Fix uses of uninitialized memory, and incorrect types for initializers.
From ITOH Yasufumi, PR 5861.
 1.4 22-Feb-1998  christos WARNSify
 1.3 03-Nov-1997  cgd implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.
 1.2 03-Jul-1995  cgd branches: 1.2.4;
RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.2.4.1 04-Nov-1997  thorpej Pull up from trunk: make renaming work and other minor fixes.
 1.8.4.1 22-Jun-2004  tron Pull up revision 1.9 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.9.36.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.29.2.1 02-Aug-2025  perseant Sync with HEAD
 1.30 24-May-2025  rillig lint: constify
 1.29 16-May-2025  rillig lint: clean up
 1.28 27-Feb-2025  rillig lint: normalize whitespace
 1.27 03-Dec-2023  rillig branches: 1.27.2;
lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.26 03-Dec-2023  rillig lint: re-wrap comments

No functional change.
 1.25 03-Dec-2023  rillig lint: move function body brace to the left

No functional change.
 1.24 13-Jul-2023  rillig lint: indent copyright lines consistently
 1.23 10-Jul-2023  rillig lint: clean up lint2
 1.22 07-Feb-2022  rillig lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.
 1.21 22-Dec-2021  rillig lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.
 1.20 01-Nov-2021  rillig lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.
 1.19 29-Aug-2021  rillig lint: un-abbreviate members of sym_t

No functional change.
 1.18 29-Aug-2021  rillig lint: in debug mode, use proper type for sym_t.s_def
 1.17 28-Aug-2021  rillig lint: un-abbreviate unsigned integer types

No functional change.
 1.16 22-Aug-2021  rillig lint: save some memory

Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members
shared storage. Restore that using smaller types.

No functional change.
 1.15 22-Aug-2021  rillig lint: convert TP from macro to inline function

No functional change.
 1.14 10-Apr-2021  rillig lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.
 1.13 19-Feb-2021  rillig lint: rename t_isenum and t_aincompl to be more expressive

No functional change.
 1.12 02-Jan-2021  rillig lint: use bool instead of u_int:1 in structures

Better late than never.
 1.11 30-Dec-2020  rillig lint: rename more _nxt members to _next
 1.10 30-Dec-2020  rillig lint: rename s_nxt to s_next
 1.9 29-Dec-2020  rillig lint: fix typo in comments
 1.8 26-Dec-2017  christos Don't print duplicate definitions for inline symbols.
 1.7 07-Apr-2005  christos Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.
 1.6 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.5 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.4 03-Nov-1997  cgd branches: 1.4.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.
 1.3 22-Dec-1996  cgd branches: 1.3.2;
* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.
 1.2 03-Jul-1995  cgd RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.3.2.1 04-Nov-1997  thorpej Pull up from trunk: make renaming work and other minor fixes.
 1.4.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.27.2.1 02-Aug-2025  perseant Sync with HEAD
 1.36 24-May-2025  rillig lint: constify
 1.35 03-Dec-2023  rillig branches: 1.35.2;
lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.34 13-Jul-2023  rillig lint: indent copyright lines consistently
 1.33 10-Jul-2023  rillig lint: replce sprintf with snprintf

Even though the sprintf calls were safe, they looked suspicious.

No functional change.
 1.32 10-Jul-2023  rillig lint: clean up lint2
 1.31 03-Jul-2023  rillig lint: sync usage messages with reality
 1.30 03-Jul-2023  rillig lint: invert the -u, -v and -z flags

Now they behave the same as in the manual page.

No functional change.
 1.29 09-Jun-2023  rillig lint: indent local variables consistently

No binary change.
 1.28 28-Mar-2023  rillig lint: warn about extern declarations outside headers

https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
 1.27 21-Feb-2023  rillig lint: return instead of calling exit from main

No functional change.
 1.26 14-Jan-2023  rillig lint: rename lint2 functions to be more expressive
 1.25 13-Jan-2023  rillig lint: remove custom memory allocator

Besides adding complexity, the custom memory allocator didn't invalidate
freed memory, which made it harder to find possible use-after-free bugs.
 1.24 20-May-2022  rillig lint: use __RCSID in lint mode as well

Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
 1.23 16-Nov-2021  rillig lint: clean up initialization of lint2 symbol table

No functional change.
 1.22 05-Sep-2021  rillig lint: hide irrelevant type information from lint2

No functional change.
 1.21 28-Aug-2021  rillig lint: sort the lint2 diagnostics by symbol name
 1.20 28-Aug-2021  rillig lint: remove unused parameter from forall

No functional change.
 1.19 22-Aug-2021  rillig lint: constify lint2 checking functions

No functional change.
 1.18 11-Aug-2021  rillig lint: add reminder to sort the output of lint2
 1.17 18-Apr-2021  rillig lint: remove WARNS=3, falling back to the default WARNS=5

It's strange that GCC does not warn about the nonliteral format strings
in lint1/err.c, lint2/msg.c and lint2/read.c, despite -Wformat=2, but
Clang does.
 1.16 18-Apr-2021  rillig lint: clean up option parsing
 1.15 02-Apr-2021  rillig lint: add parentheses after sizeof, as required by share/misc/style

No functional change.
 1.14 26-Mar-2021  rillig lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'

No functional change.
 1.13 16-Jan-2021  rillig lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once. See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode. The only missing thing was using the constant
literals false and true instead of 0 and 1. For sure there are some
integer literals left that can be converted. For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.
 1.12 12-Jan-2021  rillig lint: update usage for lint1 and lint2

(Forgotten in the previous commit.)
 1.11 12-Jan-2021  rillig lint: add new check for strict bool mode

In strict bool mode, bool is considered incompatible with all other
scalar types, just as in Java, C#, Pascal.

The controlling expressions in if statements, while loops, for loops and
the '?:' operator must be of type bool. The logical operators work on
bool instead of int, the bitwise operators accept both integer and bool.
The arithmetic operators don't accept bool.

Since <stdbool.h> implements bool using C preprocessor macros instead of
predefining the identifiers "true" and "false", the integer constants 0
and 1 may be used in all contexts that require a bool expression.
Except from these, no implicit conversion between bool and scalar types
is allowed.

See usr.bin/tests/xlint/lint1/d_c99_bool_strict.c for more details.

The command line option -T has been chosen because all obvious choices
(-b or -B for bool, -s or -S for strict) are already in use. The -T may
stand for "types are checked strictly".

The default behavior of lint doesn't change. The strict bool check is
purely optional.

An example program for strict bool mode is usr.bin/make, which has been
using explicit comparisons such as p != NULL, ch != '\0' or n > 0 in
most places for a long time now, even before the refactoring in 2020.
 1.10 04-Jan-2021  rillig lint: fix typos and other minor stylistic issues
 1.9 05-Sep-2016  sevan Drop main() prototype.
 1.8 14-Jan-2010  christos Add a list of functions where we usually don't care about their return
code. Can be bypassed by -hh
 1.7 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.6 31-Jan-2002  tv branches: 1.6.4;
Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.5 21-Nov-2001  wiz "than" instead of "then".
 1.4 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.3 22-Feb-1998  christos WARNSify
 1.2 03-Jul-1995  cgd RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.6.4.1 22-Jun-2004  tron Pull up revision 1.7 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.35.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 13-Jan-2023  rillig lint: move xalloc to the only file where it is used

No functional change.
 1.16 13-Jan-2023  rillig lint: remove custom memory allocator

Besides adding complexity, the custom memory allocator didn't invalidate
freed memory, which made it harder to find possible use-after-free bugs.
 1.15 20-May-2022  rillig lint: use __RCSID in lint mode as well

Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
 1.14 31-Aug-2021  rillig lint: fix memory allocation (since 2021-08-28)

In mem1.c 1.50 and mem2.c 1.13 from 2021-08-28, I accidentally changed
the initialization of mblklen from round_up to round_down, trying to
avoid a division instruction.

On NetBSD x86_64 this resulted in a few more malloc calls, but on Cygwin
with its 64k pagesize, mblklen became 0. Later, the function xalloc in
lint2 called xalloc(mblklen) and blindly assumed that the returned
memory would be large enough. This in turn led to out-of-bounds memory
access and crashes. Lint1 was not affected since it adjust mblklen
during runtime if it gets too small.
 1.13 28-Aug-2021  rillig lint: use 'unsigned int' for bit-size of types

Lint does not need to support any types larger than 256 MB since they
don't occur in practice. Practically, such large types have never been
supported at all since the function type_size_in_bits used int for the
internal calculations, resulting in overflows.
 1.12 01-Aug-2021  rillig lint: remove xmapalloc

Just trust the standard malloc to be smart enough.

No functional change.
 1.11 29-Dec-2020  rillig lint: remove redundant parentheses around return value
 1.10 28-Dec-2020  rillig lint: sort includes
 1.9 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.8 21-Oct-2003  christos branches: 1.8.2;
PR/23219: Dan McMahill: Make this compile on system that don't have MAP_ANON.
Centralize the mmap allocations in a new function, xmapalloc() that handles
this.
 1.7 31-Jan-2002  tv Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.6 21-Jan-2002  tv Add hooks for compiling on non-NetBSD hosts.
 1.5 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.4 22-Feb-1998  christos WARNSify
 1.3 02-Oct-1995  jpo support asm statements and asm modifiers in declarations

asm statements consist of an asm keyword, an optional qualifier, a
left paren, a list of tokens up to and including the matching right
paren, and a semicolon.

asm modifiers consist of an asm keyword, an left paren, a string and a
right paren.

asm statements and modifiers have no semantic for lint(1), they exist only
to avoid complaints about them.
 1.2 03-Jul-1995  cgd RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.8.2.1 22-Jun-2004  tron Pull up revision 1.9 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.27 24-May-2025  rillig lint: fix wording in a warning about a type conflict

An object does not have a return type, only functions do.
 1.26 30-Nov-2024  rillig lint: reword lint2 warnings, reduce punctuation

The previous diagnostics used unusual punctuation, for example by placing
spaces inside parentheses, as well as using space-space-tab and
double-colon as separators. Convert these diagnostics into readily
readable prose, and mark them clearly as coming from lint2, so that they
can be related to the tests in /usr/tests/usr.bin/xlint/lint2/msg_???.ln.

This change means that usr.bin/error no longer recognizes these messages
as coming from lint2, but that can be fixed later if necessary.
 1.25 03-Dec-2023  rillig branches: 1.25.2;
lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.24 13-Jul-2023  rillig lint: indent copyright lines consistently
 1.23 10-Jul-2023  rillig lint: push memory management one layer down

Just as with type_name in lint1, it is more convenient if the
application code does not have to deal with memory management.
 1.22 10-Jul-2023  rillig lint: replce sprintf with snprintf

Even though the sprintf calls were safe, they looked suspicious.

No functional change.
 1.21 10-Jul-2023  rillig lint: clean up lint2
 1.20 09-Jun-2023  rillig lint: indent local variables consistently

No binary change.
 1.19 19-Feb-2023  rillig lint: make basename simpler

There is no need to handle trailing slashes since lint only handles
regular files in diagnostics, not directories. Furthermore, only the
last '/' was ignored, but multiple trailing slashes would not.
 1.18 02-Feb-2023  rillig lint: clean up

In symtab_search, most of the conditions were redundant, so remove them.

In read_byte, using CHAR_MASK was conceptually wrong, as that constant
is from the target platform while the lexical analysis happens on the
host platform. It was unnecessary as well, as a hypothetical host
platform with 36-bit chars might encode the characters from the basic
source character set as numbers higher than 0x0_0000_00ff. Since lint
assumes that both the source character set as well as the execution
character set are the same and based on 8-bit bytes, nothing changes.

No functional change.
 1.17 20-May-2022  rillig lint: use __RCSID in lint mode as well

Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
 1.16 28-Aug-2021  rillig lint: un-abbreviate unsigned integer types

No functional change.
 1.15 27-Mar-2021  rillig lint: remove space between 'sizeof ('

No functional change.
 1.14 16-Jan-2021  rillig lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once. See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode. The only missing thing was using the constant
literals false and true instead of 0 and 1. For sure there are some
integer literals left that can be converted. For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.
 1.13 29-Dec-2020  rillig lint: remove redundant parentheses around return value
 1.12 28-Dec-2020  rillig lint: sort includes
 1.11 24-May-2011  joerg Fix format string usage
 1.10 26-Apr-2008  christos print the types involved in the mismatch.
 1.9 07-Apr-2005  christos branches: 1.9.20;
Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.
 1.8 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.7 31-Jan-2002  tv branches: 1.7.4;
Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.6 21-Jan-2002  tv Add hooks for compiling on non-NetBSD hosts.
 1.5 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.4 22-Feb-1998  christos WARNSify
 1.3 03-Nov-1997  cgd implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.
 1.2 03-Jul-1995  cgd branches: 1.2.4;
RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.2.4.1 04-Nov-1997  thorpej Pull up from trunk: make renaming work and other minor fixes.
 1.7.4.1 22-Jun-2004  tron Pull up revision 1.8 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.9.20.1 18-May-2008  yamt sync with head.
 1.25.2.1 02-Aug-2025  perseant Sync with HEAD
 1.93 30-Nov-2024  rillig lint: reword lint2 warnings, reduce punctuation

The previous diagnostics used unusual punctuation, for example by placing
spaces inside parentheses, as well as using space-space-tab and
double-colon as separators. Convert these diagnostics into readily
readable prose, and mark them clearly as coming from lint2, so that they
can be related to the tests in /usr/tests/usr.bin/xlint/lint2/msg_???.ln.

This change means that usr.bin/error no longer recognizes these messages
as coming from lint2, but that can be fixed later if necessary.
 1.92 12-May-2024  rillig branches: 1.92.2;
lint: add wrapper for <ctype.h> functions, for strict bool mode

When using the Clang preprocessor (with MKLLVM=yes), the preprocessor
output does not indicate which tokens come from a system header and
which tokens come from the user code. Lint's strict bool mode relies on
this information to treat the character classification functions from
<ctype.h> as if their return type were bool instead of int.

These wrapper functions are only used when their argument is indeed a
'char', but not when the argument might be 'EOF or representable as an
unsigned char', such as when reading a byte from the input.
 1.91 02-Mar-2024  rillig lint: remove custom wrappers around <ctype.h> functions
 1.90 03-Dec-2023  rillig lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.89 03-Dec-2023  rillig lint: re-wrap comments

No functional change.
 1.88 03-Dec-2023  rillig lint: indent statement continuations consistently

No binary change.
 1.87 13-Jul-2023  rillig lint: indent copyright lines consistently
 1.86 10-Jul-2023  rillig lint: push memory management one layer down

Just as with type_name in lint1, it is more convenient if the
application code does not have to deal with memory management.
 1.85 10-Jul-2023  rillig lint: clean up lint2
 1.84 10-Jul-2023  rillig lint: clean up wchar_t and hash tables
 1.83 08-Jul-2023  rillig lint: enable more lint warnings for its own source code
 1.82 03-Jul-2023  rillig lint: rename uppercase QUAD to LLONG

No binary change.
 1.81 09-Jun-2023  rillig lint: indent local variables consistently

No binary change.
 1.80 22-May-2023  rillig lint: rename constant NOTSPEC to NO_TSPEC

It was too easy to misread the old name as NOT_SPEC instead of the
intended NO_TSPEC.
 1.79 21-Feb-2023  rillig lint: use __printflike
 1.78 14-Jan-2023  rillig lint: clean up messages for internal errors
 1.77 13-Jan-2023  rillig lint: move xalloc to the only file where it is used

No functional change.
 1.76 20-May-2022  rillig lint: use __RCSID in lint mode as well

Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
 1.75 19-Dec-2021  rillig lint: remove redundant braces

No binary change.
 1.74 19-Dec-2021  rillig lint: reduce pointer usage when reading .ln lines

No binary change.
 1.73 19-Dec-2021  rillig lint: remove unused parameter in read_ln_line
 1.72 16-Dec-2021  rillig lint: improve error message for missing newline in .ln file
 1.71 28-Nov-2021  rillig lint2: in case of parse errors, output the offending line

This provides more of a clue than a simple '(not alnum or _: )',
especially in the output of build.sh.

While here, change the format of the error message to the standard
'%s:%d'. Since these are internal errors, they are not supposed to occur
often, so no need to change error(1).
 1.70 28-Nov-2021  rillig lint: move fgetln peculiarities out of read_ln_line

This allows the function parameter to be a pointer to const.

No functional change.
 1.69 16-Nov-2021  rillig lint: clean up lint2

No functional change.
 1.68 16-Nov-2021  rillig lint: clean up initialization of lint2 symbol table

No functional change.
 1.67 05-Sep-2021  rillig lint: remove source code references from internal error message

The additional strings that are provided with the error message are
distinctive enough.
 1.66 05-Sep-2021  rillig lint: extract function for reading a single line from a .ln file

No functional change.
 1.65 05-Sep-2021  rillig lint: fix some more lint warnings

The only remaining warnings are in scan.c, which is a generated Flex
scanner.

No functional change.
 1.64 04-Sep-2021  rillig lint: reduce complexity of reading a function call

No functional change.
 1.63 30-Aug-2021  rillig lint: extract parse_function_attribute from decldef

No functional change.
 1.62 30-Aug-2021  rillig lint: remove redundant call to strchr in decldef

This time, the branches for varargs, printflike and scanflike in the big
switch statement are covered by unit tests. These tests would have
caught the previous "cleanup" that broke parsing of these function
attributes. Furthermore, this second cleanup is closer to the original
code and conceptually simpler since it avoids having many 'continue'
statements in a 'switch' statement, which would have been unusual.

The branches for inline functions and used functions are still not
covered by the tests, but they are structurally equal to several other
branches.

No functional change.
 1.61 30-Aug-2021  rillig lint: revert "remove redundant call to strchr" from yesterday

This "refactoring" broke the parsing code for varargs, printflike and
scanflike functions, and there were no tests for these. Revert for now,
maybe try again later, after adding the corresponding tests.
 1.60 30-Aug-2021  christos Move the character one back so that we don't increment twice
 1.59 30-Aug-2021  christos Skip the current character before parsing the number of arguments.
 1.58 29-Aug-2021  rillig lint: remove redundant call to strchr
 1.57 29-Aug-2021  rillig lint: un-abbreviate members of sym_t

No functional change.
 1.56 28-Aug-2021  rillig lint: un-abbreviate unsigned integer types

No functional change.
 1.55 22-Aug-2021  rillig lint: clean up error handling in lint2

These are edge cases that don't happen in practice, therefore reduce the
size of the binary.
 1.54 22-Aug-2021  rillig lint: use unsigned integers for storing hash values

The computation of the hash values is unchanged, only the resulting
value (which is always less than 1009 anyway, see HSHSIZ2) is stored as
unsigned as well.

No functional change.
 1.53 22-Aug-2021  rillig lint: simplify reading of type qualifiers in lint2

The only producer of .ln files is lint1, which always writes the type
qualifiers in the order 'c', 'v', therefore there is no need to expect
any other order or check for duplicates. There is no ambiguity since
the other type modifiers are neither 'c' nor 'v' and the main types are
all uppercase letters.

No functional change.
 1.52 22-Aug-2021  rillig lint: clean up switch statements in gettlen

Since the switch statements are only about tagged and derived types,
there is no need to list all integer and floating types.

No functional change.
 1.51 22-Aug-2021  rillig lint: convert TP from macro to inline function

No functional change.
 1.50 22-Aug-2021  rillig lint: extract parse_tspec from inptype

Add error handling for unknown type character, which led to read of
uninitialized memory before. No practical change as far as lint2 only
ever reads output from lint1, since that is well-formed.
 1.49 08-Aug-2021  rillig lint: force strict bool mode

No functional change.
 1.48 05-Aug-2021  rillig lint: fix type of local variable in inpqstrg

Noted by Clang-Tidy.
 1.47 05-Aug-2021  rillig lint: fix handling of __int128_t/__uint128_t in lint2

Previously, lint exited with "bad type: J u".
 1.46 31-Jul-2021  rillig lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.
 1.45 18-Apr-2021  rillig lint: remove WARNS=3, falling back to the default WARNS=5

It's strange that GCC does not warn about the nonliteral format strings
in lint1/err.c, lint2/msg.c and lint2/read.c, despite -Wformat=2, but
Clang does.
 1.44 18-Apr-2021  rillig lint: reduce duplicate code for parsing .ln files
 1.43 18-Apr-2021  rillig lint: fix error message in lint2 for missing record type in .ln file
 1.42 02-Apr-2021  rillig lint: add parentheses after sizeof, as required by share/misc/style

No functional change.
 1.41 26-Mar-2021  rillig lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'

No functional change.
 1.40 28-Feb-2021  rillig lint2: align comments in the code with actual messages
 1.39 19-Feb-2021  rillig lint: rename t_isenum and t_aincompl to be more expressive

No functional change.
 1.38 16-Jan-2021  rillig lint: replace integer constant expressions with true and false

LINTFLAGS=-gST make lint, with manual review.

The error messages from lint are all correct, they are not complete
though. The return value of a function returning bool may still be
compared to the integer 0.
 1.37 16-Jan-2021  rillig lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once. See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode. The only missing thing was using the constant
literals false and true instead of 0 and 1. For sure there are some
integer literals left that can be converted. For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.
 1.36 04-Jan-2021  rillig lint: fix typos and other minor stylistic issues
 1.35 01-Jan-2021  rillig lint: remove NTSPEC from enum tspec_t

The number of elements in an enumeration is not a valid enum constant of
that enumeration itself.
 1.34 30-Dec-2020  rillig lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.
 1.33 30-Dec-2020  rillig lint: rename more _nxt members to _next
 1.32 30-Dec-2020  rillig lint: rename s_nxt to s_next
 1.31 29-Dec-2020  rillig lint: fix indentation and alignment that used space-tab
 1.30 29-Dec-2020  rillig lint: remove redundant parentheses around return value
 1.29 28-Dec-2020  rillig lint: sort includes
 1.28 07-Sep-2018  christos recognize int128
 1.27 26-Dec-2017  christos branches: 1.27.2; 1.27.4;
Don't print duplicate definitions for inline symbols.
 1.26 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.25 15-Apr-2009  christos Lukemify (WARNS=4)
 1.24 14-Apr-2009  lukem Fix -Wshadow and -Wcast-qual issues
 1.23 26-Sep-2008  matt branches: 1.23.6;
Teach lint about long double _Complex (C99)
 1.22 26-Apr-2008  christos make the complex float/double annotated consistently with regular float/double.
 1.21 26-Apr-2008  christos - simplify logic in getting the filename index.
- fix an allocation botch.
 1.20 25-Apr-2008  christos preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.
 1.19 28-Sep-2007  uwe branches: 1.19.6;
tlst[inptype(...)] is bad C code because inptype() can realloc tlst
and there's no intermediate sequence point! We actually hit this on
sh3 with -O2 where gcc4 caches tlst in a register prior to recursive
call to inptype() and if you are unlucky the recursive call needs to
realloc tlst.

Introduce a temp variable to force a sequence point.
 1.18 22-Mar-2006  christos branches: 1.18.6; 1.18.8; 1.18.12;
gcc says case is missing, coverity says case not reached. Appease both.
 1.17 22-Mar-2006  christos Coverity CID 46: Remove dead code.
 1.16 16-Jul-2005  christos - make input errors print the lint source line number they are called from.
- simplify a conditional.
 1.15 12-Sep-2004  yamt recognize _Bool.
 1.14 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.13 31-Jan-2002  tv branches: 1.13.4;
Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.12 21-Jan-2002  tv Add hooks for compiling on non-NetBSD hosts.
 1.11 03-Jan-2002  tron Add "case" statements for "NTSPEC" to fix "gcc" warnings.
 1.10 26-Jul-2001  wiz Various typos in comments (neccessary, sceme, choise, ...).
 1.9 28-May-2001  lukem cleanup (prior to more adding more features):
- convert to ANSI KNF
- remove trailing whitespace
- translate some comments from german into english

code compiles and runs clean, and tested by running "make lint" against
xlint source using previous and this lint produces same results.
 1.8 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.7 20-Dec-1998  christos branches: 1.7.8;
char -> unsigned char
 1.6 27-Jul-1998  mycroft Fix uses of uninitialized memory, and incorrect types for initializers.
From ITOH Yasufumi, PR 5861.
 1.5 22-Feb-1998  christos WARNSify
 1.4 03-Nov-1997  cgd implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.
 1.3 22-Dec-1996  cgd branches: 1.3.2;
* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.
 1.2 03-Jul-1995  cgd RCS id cleanup
 1.1 03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.3.2.1 04-Nov-1997  thorpej Pull up from trunk: make renaming work and other minor fixes.
 1.7.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.13.4.1 22-Jun-2004  tron Pull up revision 1.14 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.18.12.1 06-Nov-2007  matt sync with HEAD
 1.18.8.1 30-Sep-2007  wrstuden Catch up w/ last night's netbsd-4
 1.18.6.1 28-Sep-2007  xtraeme Pull up following revision(s) (requested by uwe in ticket #907):
usr.bin/xlint/lint2/read.c: revision 1.19

tlst[inptype(...)] is bad C code because inptype() can realloc tlst
and there's no intermediate sequence point! We actually hit this on
sh3 with -O2 where gcc4 caches tlst in a register prior to recursive
call to inptype() and if you are unlucky the recursive call needs to
realloc tlst.
Introduce a temp variable to force a sequence point.
 1.19.6.1 18-May-2008  yamt sync with head.
 1.23.6.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.27.4.1 10-Jun-2019  christos Sync with HEAD
 1.27.2.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.92.2.1 02-Aug-2025  perseant Sync with HEAD

RSS XML Feed