Commit Graph

20704 Commits

Author SHA1 Message Date
andvar 947fbafb45 fix typos, mainly s/unsupport/unsupported/ in log messages. 2024-02-02 22:33:42 +00:00
rillig 8016349204 lint: fix debug output for strings, reduce code size
The debug output contained too many newlines.

The buffer functions were built into lint2 even though they weren't
used.

Enable the query for invisible characters in string literals, to make
sure that a newline in a string literal does not trigger that query.
2024-02-02 16:25:58 +00:00
rillig 402b4579b3 lint: make newline in a string literal an error in C90 and later 2024-02-02 16:05:37 +00:00
rillig 2f96b2b84b lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent
quadratic runtime when concatenating string literals.
2024-02-01 21:19:13 +00:00
rillig c9edda031f lint: use standard buffer for storing string values
No functional change.
2024-02-01 18:37:06 +00:00
christos 283a7ed9be fix tools build 2024-01-29 22:01:58 +00:00
christos ed7b026d6f PR/57891: Ricardo Branco: add symbolic flags printing (from FreeBSD) 2024-01-29 21:55:24 +00:00
rillig 9e650a18b6 lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format
strings; lint has no similar check for wide strings. These format
strings are checked by modern compilers, making this check less
relevant.
2024-01-29 21:30:24 +00:00
rillig 49766a0931 lint: check getopt call more strictly
Previously, '(c = getopt(...)) != -2' would match as well.
2024-01-29 21:04:21 +00:00
rillig 8c7fbc585c lint: fix type of large integer constants 2024-01-27 20:03:14 +00:00
christos 063b07317d PR/57875: Jason Bacon: Try again without an _ for portability. 2024-01-27 16:04:36 +00:00
rillig 708007c3c9 lint: split determining the type of an integer constant
No functional change.
2024-01-27 15:53:27 +00:00
rillig 32781b5733 lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since
C90 is an edge case that should not clutter the main code of determining
the resulting type of the constant.

The code for lexing an integer constant doesn't implement the C99 rules
yet, which convert a constant to the 'long long' types if the 'long'
types don't suffice.
2024-01-27 12:14:58 +00:00
sjg 384f068bd8 Note that in both :U and :D newval may be empty 2024-01-25 21:00:59 +00:00
sjg b0fb99a891 Indicate that for :U newval is optional 2024-01-25 07:35:46 +00:00
rillig c6c7f59fad lint: unconst parameters
These were leftovers from earlier refactorings and are no longer needed.

No binary change.
2024-01-23 20:03:42 +00:00
rillig 09702fc7eb lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt),
so rename all related identifiers to be more distinctive.

No functional change.
2024-01-23 19:44:28 +00:00
rillig 9b86db195b make: refactor CondParser_Term to be inlinable
No functional change.
2024-01-21 16:32:41 +00:00
rillig d2763e34bd make: clean up parsing of conditions
No functional change.
2024-01-21 15:22:55 +00:00
rillig 2192214d0f make: clean up redundant 'const' from automatic variables
No binary change.
2024-01-21 15:02:17 +00:00
rillig 8ecccbd3a1 lint: on lint itself, disable query for const variables again
It suffixes to perform this check on demand.
2024-01-21 14:59:18 +00:00
rillig f7651e613b lint: clean up redundant const from parameters and local variables
These were leftovers from splitting large functions into smaller
functions, to ensure that variables were not unintentionally reassigned.
Those refactorings are finished, and the extra help from the compiler is
no longer necessary.

No binary change.
2024-01-21 14:21:34 +00:00
rillig 330a6ad5ca lint: create .ln output file even when queries are enabled
This allows to configure lint flags in mk.conf globally for a whole
NetBSD build.  Previously, this would have made the build fail due to
missing .ln files.

The previous use case of rerunning lint with or without queries is easy
enough to achieve by doing a 'make clean', in the same way as for lint
warnings.
2024-01-21 14:11:52 +00:00
rillig 9de7a84bd2 lint: clean up 2024-01-20 12:02:09 +00:00
rillig 7c3b3207ed lint: unclutter conditional compilation 2024-01-20 10:25:57 +00:00
rillig e6919d40e3 lint: only define xcalloc if actually used 2024-01-20 10:21:35 +00:00
rillig 45efdafbcc lint: add query for const automatic variables 2024-01-20 10:02:31 +00:00
rillig 6f23d4df44 lint: allow '\e' only in GCC mode 2024-01-19 19:23:34 +00:00
christos 7ad74d8547 add \e 2024-01-19 18:23:13 +00:00
thorpej 90a3cb0405 Bump version. 2024-01-18 05:41:38 +00:00
thorpej e407e52763 With config(1) as it exists today, a kernel Makefile is able to implement
logic on kernel options so long as those options are not defflag'd or
defparam'd.  This works because such options are automatally added to the
IDENT var in the kernel Makefile as a preprocessor define, and the Makefile
can then do an operation like:

.if !empty(IDENT:M-DSOMECOOLCPUOPTION)
CFLAGS+= -mcpu=somecoolcpu
.endif

Unfortunately, this precludes making it possible to generate a compile-time
dependency on SOMECOOLCPUOPTION, or having SOMECOOLCPUOPTION imply another
kernel config option using the normal config(1) option dependency function.

Fix this by introducing a new option description keyword: mkflagvar.  This
keyword marks an already defflag'd option as wanting a kernel Makefile var
defined if that option is selected in the kernel config file.  So:

defflag opt_coolcpu.h SOMECOOLCPUOPTION ANOTHERCOOLCPUOPTION
mkflagvar SOMECOOLCPUOPTION ANOTHERCOOLCPUOPTION

will cause:

KERNEL_OPT_SOMECOOLCPUOPTION="1"
KERNEL_OPT_ANOTHERCOOLCPUOPTION="1"

...to be emitted into the kernel Makefile if those options are, in fact,
selected with "options ..." in the kernel config file, thus allowing for
a compile-time dependency on the option to be generated in addition to
Makefile logic, which now looks like:

.if !empty(KERNEL_OPT_SOMECOOLCPUOPTION)
CFLAGS+= -mcpu=somecoolcpu
.endif
2024-01-18 04:41:37 +00:00
christos 3679c205f3 PR/57858: Ricardo Branco: Print the full pathname on errors.
from FreeBSD https://github.com/NetBSD/src/pull/25
2024-01-15 17:35:48 +00:00
mrg ef77be638e set file flags after setting other modes
otherwise permission to set modes may be revoked by the flags.
from PR#57855.  thanks!

XXX: pullup-all
2024-01-14 18:12:59 +00:00
christos 2782716bca better check st_size == 0, than st_dev == -1 2024-01-14 17:40:17 +00:00
christos 04bf1397ad Better check against st_size == 0 instead of st_dev == -1 2024-01-14 17:39:19 +00:00
christos e39dc43f61 PR/57850: Ricardo Branco: tail does not work in some pseudo-filesystems
From FreeBSD: https://github.com/NetBSD/src/pull/20
2024-01-14 17:37:32 +00:00
christos f4066449c8 PR/57854: Richardo Branco: wc -c does not work on procfs/kernfs 2024-01-14 17:16:10 +00:00
christos dfd2ee048f PR/57851: Ricardo Branco: stat(2) does not return correct size information
for kernfs/procfs files. Minor KNF.
2024-01-14 16:42:58 +00:00
rillig 312b884dfe lint: clean up grammar for initializers 2024-01-13 11:24:57 +00:00
rillig c8c38278b0 lint: inline simple grammar rules 2024-01-13 01:23:39 +00:00
rillig 1e0bac8ba8 lint: clean up grammar for array size 2024-01-12 08:33:39 +00:00
rillig 0153f4c1c0 lint: clean up enum constants for designators
In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.
2024-01-11 23:26:39 +00:00
rillig d3fa5ab1cc lint: correctly set system-header flag on cast-expression
When a cast-expression comes partly from a system header, determine at
the ')' whether the whole cast-expression comes from the system header.
Previously, it was based on the operand, which contradicted the
documentation of tn_sys.

Mainly affects strict bool mode (where expressions from system headers
are handled more leniently), as well as query 9 for parenthesized return
expressions.

Discovered upon manual inspection, as calling expr_alloc_tnode should
never be necessary when creating an expression node with operands;
there's build_op for that purpose.
2024-01-11 23:06:19 +00:00
rillig e1fc9df408 lint: warn about integer overflow when folding constant INT_MIN / -1 2024-01-11 20:25:04 +00:00
rillig 75b2f6328c lint: disable -ftrapv for vax
When compiling lint1/cgram.c:
during RTL pass: postreload
cgram.c: In function 'yyparse':
cgram.c:5873:1: internal compiler error: in reload_combine_note_use,
    at postreload.c:1534
2024-01-11 04:45:20 +00:00
riastradh 679f6f2d1c getaddrinfo(1): Omit needless whitespace.
No functional change intended.
2024-01-10 01:48:16 +00:00
rillig 4b7b10e320 lint: allow complex offsetof(type, member-designator)
Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.
2024-01-09 23:46:54 +00:00
rillig 74d7189882 lint: allow querying for invisible characters in literals and constants 2024-01-07 18:42:37 +00:00
rillig 7762dd1cfb lint: fix crash for invalid __func__ (since 2023-01-29) 2024-01-07 12:43:16 +00:00
rillig f30e56dbd1 lint: fix memory allocation names, eliminate double negation 2024-01-07 12:20:42 +00:00