Commit Graph

20917 Commits

Author SHA1 Message Date
rillig def8e1797a lint: do not convert array subscripts from size_t to ptrdiff_t
The C standards do not specify a fixed type for an array subscript, it
just has to be an integer type.  Previously, query 4 fired for the
ubiquitous expression 'ptr[sz]' when sz had type 'size_t'.

The test platform_ilp32_long is unaffected by this change, as the
integer constant 0x80000000 has type 'unsigned int', while size_t is
'unsigned long' on those platforms, and even though the types 'unsigned
int' and 'unsigned long' have the same value space, there's still a
conversion, at least for now.
2024-03-30 17:12:26 +00:00
rillig c6466ed0f7 lint: reword messages about array subscripts to sound more natural 2024-03-30 16:47:44 +00:00
rillig 1219592417 lint: clean up 2024-03-29 08:35:31 +00:00
rillig 55398a9a51 lint: fix wording of warning about bit-field initializer 2024-03-29 07:35:45 +00:00
rillig 134116ce30 lint: clean up 2024-03-28 21:04:48 +00:00
rillig 30c6c279e2 lint: add missing assignment to $$ in grammar
Byacc and Bison both provide this assignment for all actions, whether
default or not, but the wording in POSIX doesn't guarantee this.
2024-03-27 21:14:09 +00:00
rillig 8910413e27 lint: clean up; extend overflow test 2024-03-27 20:09:43 +00:00
rillig e57698da95 lint: don't use 'long' in diagnostics
The size of 'long' differs between 64-bit and 32-bit platforms.
Eliminate this possible platform-dependency.
2024-03-27 19:28:20 +00:00
rillig 216c89c02b lint: fix warnings about loss of accuracy on bit-field operations 2024-03-25 23:39:13 +00:00
rillig 64230f3217 lint: rename snprintb 'directives' to 'conversions'
This aligns the terminology with the snprintf function.
2024-03-25 22:37:43 +00:00
mrg 707adea339 match message & conversion function name properly.
probably should make this into an array with two members.
2024-03-20 20:19:31 +00:00
mrg eb1fa7eb4a audio_wav_parse_hdr: handle zero-length data files again
the previous clean up turns zero-length data into no data and thus
an error, instead of simply doing nothing.  noted by gson.
2024-03-20 20:18:39 +00:00
rillig d7b3b04319 lint: keep invalid arguments in function calls
Previously, arguments of incomplete type or 'void' cleared all arguments
of the function call expression, requiring extra checks in later checks.

Invalid function calls are now exported to the .ln files, but that's
irrelevant in practice as these invalid function calls make lint1 fail,
after which xlint removes the .ln file.
2024-03-19 23:19:03 +00:00
andvar a5c0af2445 Add missing "e" in few words, in comments and one log message. 2024-03-17 21:48:01 +00:00
andvar bb2336b065 s/argumment/argument/ in documentation. 2024-03-17 21:37:53 +00:00
ryoon 5970d5082c Remove debug print 2024-03-16 23:40:25 +00:00
rillig 083828859c stat: don't allow numeric formatting flags on strings
Calling snprintf with "%+s" invokes undefined behavior.
2024-03-14 21:17:54 +00:00
kre cdaa157c5b While the change in 1.51 certainly retained binary compat with
what was in 1.50 (while silencing LINT) - it was clearly not the
correct change to make.   The code used !FLAG_POUND where it
clearly meant ~FLAG_POUND ... the former is 0, so &= 0 could
be replaced by =0 changing nothing.   But that's not what it
should have been doing, other flags should not have been
removed here, just FLAG_POUND.

This problem seems to have existed since support for %#s
was first added in 2011, which kind of suggests how rarely
that format, particularly with other flags (like %#-s)
has ever been used (with no other flags, the bug would not
be noticed).
2024-03-14 19:38:56 +00:00
rillig 45a5eb6da3 stat: fix lint warning about constant argument to '!'
No binary change.
2024-03-14 00:07:20 +00:00
mrg 21fadbc4fc fix some sizeof() confusion.
using "const char search[4]" as a function parameter means that
"search" is actually a pointer type so "sizeof search" returns
8 on 64-bit platforms.  i mis-read this and used "sizeof *search"
which is always 1, noted by rillig.

instead of trying to avoid writing "4" twice, put it in a define
and use that in various places instead.  annoying.
2024-03-14 00:00:31 +00:00
rillig a1988d862f lint: trim down the check for snprintb formats 2024-03-13 06:48:49 +00:00
rillig 9b239cc71c lint: fix warning about loss of conversion for unsigned bit-fields
Since decl.c 1.180 from 2021-05-02.
2024-03-12 07:56:08 +00:00
mrg c783de976f audioplay(1): handle mis-aligned RIFF chunks.
put the code to find RIFF chunks into a new find_riff_chunk() function,
and handle mis-aligned chunk lengths.  can now play files with chunks
that say they are 7 bytes long, and have 1 byte padding.

add some -V -V extra-verbose for the wav parser.
2024-03-12 00:34:38 +00:00
mrg cfa155a807 minor clean up in the RIFF/WAVE header checking.
use memcmp() not strncmp() to check for "RIFF" and "WAVE".
avoid endian convesion on part.len 3 times.
2024-03-11 23:12:29 +00:00
mrg c62cdc0d11 be sure to byte swap ext.len when checking/printing it.
noted by rillig@.
2024-03-11 19:17:52 +00:00
rillig dd848dec1a lint: add details to the message about integer overflow
Having only the operator was too unspecific to be actionable, so add the
actual numbers and the data type.
2024-03-10 19:45:14 +00:00
rillig 13c8c0a7de kdump: keep the comment with its corresponding code
No binary change.
2024-03-10 18:54:41 +00:00
christos b0c85e5803 decode some {g,s}etsockopt*. 2024-03-10 17:08:31 +00:00
rillig 7be18902ad lint: clean up tree matcher for snprintb calls 2024-03-10 16:27:16 +00:00
rillig bd9743d3db lint: saturate signed integer overflow
In array address calculations, this prevents a 'array subscript cannot
be negative' for large array subscripts.
2024-03-10 16:06:13 +00:00
rillig 08d1bd5c72 lint: fix integer overflow detection
Previously, an unsigned operation that had a negative result went
undetected in a few cases. Now, all results that are not representable
by their type are considered overflows.

The implementation of signed shift-right had been wrong for a few
commits.
2024-03-10 15:49:12 +00:00
rillig ee7b09445f lint: clean up check for overflow in integer constants 2024-03-10 14:42:04 +00:00
rillig 51858eeb3e lint: detect more cases of integer overflow in constant expressions
For unsigned integers, detect when 'a + b' wraps around.
2024-03-10 14:32:30 +00:00
rillig ee9f134f18 lint: split integer overflow check into separate functions
The checks for unsigned and signed integers differ for each operator, so
there's no point having both parts in the same function.
2024-03-10 12:50:45 +00:00
rillig 25f6e58591 lint: remove wrong warning about overflow in unary '-' for unsigned 2024-03-10 10:31:29 +00:00
rillig 34885a599d lint: fix integer overflow in integer overflow check 2024-03-10 10:15:51 +00:00
rillig c11cfaed7e lint: in check for integer overflow, sort operators 2024-03-10 09:24:54 +00:00
sjg b52179abfc make: record exit status in GNode
SetErrorVars can now set .ERROR_EXIT which allows
a .ERROR target to ignore the case of .ERROR_EXIT == 6
which means failure happened elsewhere.

Reviewed by:
2024-03-10 02:53:37 +00:00
rillig 3e856647d2 lint: fix excessive overflow warning after division by zero 2024-03-09 23:55:11 +00:00
rillig 4ed4a1b76a lint: merge duplicate code for checking array index 2024-03-09 14:54:14 +00:00
rillig 3b4840f15a lint: inline accessor macros for tnode_t 2024-03-09 13:54:47 +00:00
rillig 73c14755e5 lint: inline accessor macros for type_t 2024-03-09 13:20:55 +00:00
rillig 0644d39b2d lint: clean up comments, use typedefs 2024-03-09 11:05:05 +00:00
rillig 15d27de1fa lint: internally store case label values in order of appearance 2024-03-09 10:54:12 +00:00
rillig 70f9d5c54d lint: remove unneeded checks for left and right operands 2024-03-09 10:47:16 +00:00
rillig 5a97e61464 lint: use fewer struct keywords 2024-03-09 10:41:11 +00:00
mrg b4c3b934ba audio_wav_parse_hdr(): avoid buffer overreads and clean up
reimplement most of this function using a new method of buffer
management to ensure that we never read beyond the provided size.

properly handle RIFF chunk lengths, instead of assuming various
offsets from most files are right.

update list of consumed documentation and fill the list of WAVE
formats from RFC 2361 (most remain not supported.)

should fix PR#57973.

tested against a large number of .wav files i have handy and with
a testsuite generator that should be incoming soon.
2024-03-08 06:57:59 +00:00
rillig 975564f36a tests/make: clean up test for local scope variables
Use the same style of quotes for both kinds of variables.  To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.
2024-03-05 23:07:58 +00:00
mrg 29d939f7c2 audioplay: add -n flag that doesn't write audio data.
this will be used in an upcoming testsuite for the wav parser.
2024-03-04 06:29:35 +00:00
rillig 5926386128 lint: clean up string parsing and snprintb check 2024-03-03 16:09:01 +00:00
rillig 3d5fc26390 lint: warn about escaped snprintb directive
Repurpose message 362, as the previous version was redundant since null
bytes in old-style formats are already covered by message 371 (bit
position out of range) and 377 (redundant '\0' at the end).
2024-03-03 13:09:22 +00:00
rillig a8d07ea3d1 lint: fix warning about "empty" single-letter snprintb descriptions 2024-03-03 10:27:18 +00:00
rillig c9de07fbb0 lint: check for unreachable bits and fields in snprintb formats
While here, clean up a few existing checks.
2024-03-03 00:50:41 +00:00
rillig 1ec17c714c lint: check snprintb formats for overlapping bits and fields 2024-03-02 11:56:37 +00:00
rillig aa5782417b lint: remove custom wrappers around <ctype.h> functions 2024-03-02 09:32:18 +00:00
rillig cee0bfb19b lint: fix misleading initializer for string iterator
The field 'start' marks the start of the previous matching character,
not the current iterator position.

No binary change.
2024-03-01 21:52:48 +00:00
sjg bbd77d9b59 make: update var-scope-local test
Show what VAR value is in environment of target script.
2024-03-01 20:15:59 +00:00
rillig 38c0bdf232 lint: test format strings from snprintb calls
The functions snprintb and snprintb_m are specific to NetBSD, and their
format strings are tricky to get correct.  Provide some assistance in
catching the most common mistakes.
2024-03-01 19:39:28 +00:00
rillig 1234a824fc make: fix type mismatch in lint's strict bool mode (since today) 2024-03-01 17:53:30 +00:00
rillig 448a10168f make: remove test variant for NO_REGEX
The compile-time toggle was removed in var.c 1.1099 from 2024-02-07.
2024-03-01 17:47:05 +00:00
rillig 9e211f3599 tests/lint: remove redundant documentation 2024-03-01 17:22:55 +00:00
rillig befbe528d3 lint: fix type error in strict bool mode (since yesterday) 2024-03-01 17:14:34 +00:00
sjg 5b28ac6c57 make: export target scope values
Pass target scope to Var_ReexportVars so that a target process
will see the correct values in its env.
We must then mark any Global scope variable as unexported
so targets without local value get the Global one.
2024-03-01 16:41:42 +00:00
rillig 25d30ac62e lint1: remove redundant type table for integer constant suffixes 2024-02-29 21:37:10 +00:00
gson cca8938d5b Clean up lines containing only tabs. 2024-02-27 21:05:34 +00:00
gson ca24696e6c Clean up lines containing only spaces. 2024-02-27 20:40:29 +00:00
mlelstv c6a10ee67b Chose better number format. 2024-02-24 10:10:04 +00:00
mlelstv 06daec5d6e Don't truncate mo_descr output and protect against missing terminating NUL. 2024-02-24 09:53:26 +00:00
christos 710028cc1b default is now 16K 2024-02-19 00:15:20 +00:00
wiz 8c5ffc0fbb ftp: bump FTPBUFLEN from 4kB to 16kB
sourceforge.net returns a 5kB content-security-policy.
Analyzed by mlelstv@ who reports usual limits are between 4kB and 48kB.
2024-02-18 22:33:15 +00:00
christos b5f76c451f Add -b <buflen> to specify the buffer size. 2024-02-18 22:29:56 +00:00
jkoshy cdd0abcf1b getconf.1: Note that leading underscores in configuration
variable names are ignored by getconf(1).

While here, add a section with examples, and make the synopsis
more concise.

PR bin/57875
2024-02-18 19:35:38 +00:00
gutteridge b5ee1de45f ktrace.1: apply minor spelling consistency
Use "tracepoint" consistently, rather than a mix with "trace point",
sometimes in the same paragraph. "Breakpoint" and "tracepoint" are
most commonly rendered without the space in tech documentation, AFAIK.
2024-02-12 22:53:21 +00:00
kre 498f74e32f PR bin/57918
Redo the previous correctly, the test should be whether or not only the
bottom 32 bits are set, rather than whether any of bits 32..63 are set.
This makes no difference if u_long (or unsigned long long) is 64 bits,
it is the same test in that case, but if u_long were 128 bits there is
a notable difference (though for the particular issue observed in the PR,
it is likely to work either way).
2024-02-11 01:08:57 +00:00
christos d743ad5b0e PR/57918: Taylor R Campbell: Don't try to print symbolically ioctls that
have bits set on the high 32 bits of a 64 bit long.
2024-02-10 12:53:36 +00:00
andvar 5b075dd729 s/psuedo/pseudo/ in comments. 2024-02-10 08:36:03 +00:00
kre b064b3fad8 Add a -D option to touch, which acts like the -d option added to
chmod/chown/chgrp (probably others) in the not too far distant past,
and causes the operation to be a no-op if no actual change would be
made (avoiding updating the file's ctime for no reason).

That is, with touch, -D causes no modifying sys call to be made to
a file if that file's atime and mtime are already set to the values
that would be used.   A common case for this is when a "-r ref-file"
is also a target file for the operation.

Unfortunately -d was already taken in touch, so next best available is -D.
2024-02-10 00:19:30 +00:00
kre 69d75f9748 Add a -R option, which is identical to -r, except that if the reference file
is a symbolic link, the times to use are taken from those of the symbolic
link itself, instead of from the file it references.  If the reference file
is not a symbolic link, -R and -r are identical.

This allows the BUGS entry in the manual page to be removed.
2024-02-09 23:41:48 +00:00
andvar 100a3398b8 fix spelling mistakes, mainly in comments and log messages. 2024-02-09 22:08:30 +00:00
christos acaab79677 PR/57914: Jan-Benedict Glaw: Set reproducible timestamp
Cleanup lint.
2024-02-09 16:10:18 +00:00
rillig 82caa5d69a lint: clean up variable names, parameter order, comments
No functional change.
2024-02-08 20:59:19 +00:00
rillig 9296a8c8d9 lint: clean up redundant braces
No functional change.
2024-02-08 20:45:20 +00:00
andvar a5175f1e98 s/sharable/shareable in comments and documentation. 2024-02-08 20:11:55 +00:00
rillig 7d2bd99786 lint: clean up comments, add debug output for Bison 2024-02-08 19:32:12 +00:00
kre cfc0411834 Document the -d posix-datetime arg variation, to allow specifying
fractional seconds.   (Alternate ways to achieve that for the other
ways of specifying the date and time may be forthcoming in a future
update).

Also add a warning about the (still far) future likely change of
the interpretation of 2 digit years (the coming POSIX standard
contains a similar warning).

While here, clean up wording, some macro usage, etc etc etc...
2024-02-08 02:54:13 +00:00
kre a9640bbfb2 Check that mktime() (or timegm() the one time it is used) do not
alter any of the material fields of the struct tm that was handed
to it.   If any were altered, then the time string passed in was
not a valid time representation, and so should be rejected.

This one is not an invisible change, it prevents use of things like
"-t 202402300000"  (which previously would have been interpreted as
"-t 202403010000" - the day after the 29th of Feb in 2024).

I believe this is an improvement however, and in line with the
general intent that if you specify a date and time, that exact
date and time is what touch should be using.   It does mean that
specifying "60" for the seconds field is almost guaranteed to
fail on any POSIX system, as leap seconds simply don't exist
there (on a non-POSIX-conforming system that uses leap seconds,
the :60 should work, if specified with the correct date and time
at which the leap second actually occurs).

The one exception is when parsedate(3) is used, as that does not
do this check (which allows things like "-1 day" on the 1st of
a month to work).

(This is the last of this sequence of updates to touch.c, an
update to touch.1 follows).
2024-02-08 02:54:07 +00:00
kre 7724ab9123 Properly implement the POSIX format -d option.
Previously we have hacked that using parsedate(3) - but parsedate()
returns a time_t and consequently while it "handles" fractional seconds,
all that meant (all it really can mean) is that they're ignored.

The POSIX spec expects that (at least if the filesystem supports them)
fractional seconds can be set using the -d option.

Handle that by first attempting to parse the -d arg as a posix format
date-time string (using a reasonably strict parser), and if that fails,
then fall back on parsedate(3) to parse the arg.

If the posix format parse succeeds, the result will be the same as
parsedate(3) would return for the same string - except any fractional
seconds will be handled properly.   If it fails, then nothing changes
from what we currently do.

Note the POSIX string is
	YYYY-MM-DDThh:mm:ss[.frac][Z]
where YYYY is (at least) 4 digits (leading 0's are acceptable if
you really must!) all the MM DD hh mm ss fields are exactly 2
digits, T is either 'T' or ' ', '.' is either itself, or ',',
and 'frac' is one or more digits.  Z (if given) is 'Z'.  The
[.,]frac and Z fields are optional.   Specify a time in a
slight shorthand like 2024-2-8T7:44:20  and the POSIX parse
will fail, leaving parsedate() to handle that (which it should).
But any fractional seconds which were given would be ignored.

Doc update coming - note the doc will call the YYYY field CCYY
instead, that's just a convenience to make other parts of what
is there make more sense - it is still one 4 (or more) digit field.

This should be an almost invisible change.
2024-02-08 02:53:53 +00:00
kre bda400655a Sprinkle come const - but not too much of a good thing.
NFCI
2024-02-08 02:53:40 +00:00
kre 1a8d06c811 Parameterise the "if year < 69 it is 20xx and if >=69 it is 19xx" rule
to make it simpler to (eventually, many years hence) to change that rule
to be "if year is < NN it is 21xx and if >= NN it is 20xx" instead.

Avoid comparing a time_t to -1 directly, as time_t might be unsigned.
Instead define NO_TIME as ((time_t)-1) and compare with that instead.
This makes no difference at all when time_t is signed (as it is on
NetBSD).

Use "ss" rather than "SS" as the seconds indicators (in messages)
to match with hh (hours) and mm (minutes) rather than looking like
some relation to YY (year) MM (month) and DD (day).   Why this was
ever written as SS is beyond me, but it has been that way forever.
(doc update will follow).

Minor improvement to the error message if the arg to a -t option
is unable to be parsed correctly.

NMFCI (No meaningful...)
2024-02-08 02:53:28 +00:00
kre 9298a61de3 KNF (space after keyword, and 80 column police).
NFCI

(This is the first of a series of changes to be committed
in rapid sequence).
2024-02-08 02:53:13 +00:00
rillig a30ba4f0a2 lint: use consistent variable names, reduce code for reading a byte
No functional change.
2024-02-07 08:00:36 +00:00
rillig 26428579ad lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as
unsigned, which disagreed with the book from 1978.
2024-02-07 07:42:50 +00:00
rillig 716f56f56e make: remove redundant comments
No functional change.
2024-02-07 07:21:22 +00:00
rillig 0dd36725b6 make: remove unneeded conditional-compilation toggles
The toggles INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
GMAKEEXPORT and SUNSHCMD are no longer needed, they were unconditionally
set.

The toggle NO_REGEX was configurable from the command line, but
disabling it would result in various error messages about the unknown
':C' modifier.

OK sjg@.
2024-02-07 06:43:02 +00:00
rillig bc8fe445c4 lint: tab-align message numbers in err.c
By replacing block comments with end-of-line comments, the comments take
up less space and thus no longer require to be indented by 6 spaces.

The messages and their comments are used in 3 places: the manual page
lint.7, the err-msgs.h header for debug mode, and check-msgs.lua to
verify that the comments above the message IDs correspond to the actual
messages.

No functional change.
2024-02-06 22:47:21 +00:00
rillig c4266104cb lint.7: remove implementation details from message list
From a user's perspective, it's irrelevant whether a lint message is
generated using '%s' or '%.*s'; same for the integer widths, as they are
platform-dependent.
2024-02-06 21:28:15 +00:00
rillig 5c34ad8f3f lint: make function call arguments directly accessible
Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left.  To allow easier access to
the arguments, store them in an array instead.
2024-02-05 23:11:22 +00:00
andvar 82bba4e936 fix various typos in comments. 2024-02-05 21:46:04 +00:00
rillig 68c43e85ca make: do not evaluate indirect modifiers in parse-only mode
Discovered by sjg.
2024-02-04 10:03:10 +00:00
rillig 86d09a000c make: in parse-only mode, don't evaluate modifiers
Previously, the ':S', ':ts', ':tA' and ':from=to' modifiers were
evaluated in parse-only mode, unnecessarily.  This is only noticeable
when an indirect modifier is evaluated in parse-only mode, which is
another bug that will be fixed in a follow-up commit.
2024-02-04 09:56:24 +00:00
rillig 985de0af40 tests/make: extend test for wrong evaluation in parse-only mode 2024-02-04 09:29:50 +00:00
rillig 4aa832f99f tests/make: indirect modifiers are evaluated in parse-only mode
Found by sjg@.
2024-02-04 08:51:57 +00:00
mrg 2026b7285b update my email address. 2024-02-04 05:43:05 +00:00
mrg 8f36055f87 bump copyright and version. 2024-02-03 22:40:29 +00:00
rillig 139c6401cd lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is
probably a typo everywhere else as well.
2024-02-03 20:10:10 +00:00
rillig e6cddd1286 lint: remove excessive empty lines 2024-02-03 19:37:02 +00:00
rillig 095f481327 lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are
escaped as octal, hexadecimal or not at all.
2024-02-03 19:25:16 +00:00
rillig 29354841ac lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and
thus terminated the loop around get_escaped_char.
2024-02-03 18:58:05 +00:00
rillig ffb2a8ebeb lint: clean up comments, reduce scope of variables 2024-02-03 12:57:12 +00:00
rillig 661078afe6 lint: remove unused code for converting multibyte character sequences 2024-02-03 10:56:18 +00:00
rillig c1862de9dd lint: allow larger numbers in escapes for wide characters and strings 2024-02-03 10:01:58 +00:00
sjg 7106e16450 make: state of save_dollars affects what is a parse error
When save_dollars is false it is not a parse error to
encounter $$ rather than \$.
2024-02-03 00:20:23 +00:00
rillig 03951da31e lint: use the locale for interpreting wide character strings 2024-02-02 23:36:01 +00:00
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