Commit Graph

6611 Commits

Author SHA1 Message Date
rillig e1fc9df408 lint: warn about integer overflow when folding constant INT_MIN / -1 2024-01-11 20:25:04 +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 059939593e tests/lint: fix overflow test for 32-bit platforms (since yesterday)
Plain integer constants without suffix are first tried to fit into
'int', then 'long', but not 'long long'.  This means that numbers larger
than 32 bits must be written with the LL suffix.
2024-01-08 17:11:32 +00:00
rillig cc3c7d5b6a tests/lint: test operators, integer overflow, conversions 2024-01-07 21:19:42 +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 08e0319cf4 lint: remove redundant parentheses, braces and comments
Rename the functions for folding constant expressions, to make the
comments redundant.
2024-01-06 15:05:24 +00:00
rillig 648e87c8ee tests/lint: add spaces to expected files, for better readability 2023-12-30 22:44:22 +00:00
rillig 588350fc12 tests/lint: sync comments in test for strict bool mode with reality 2023-12-30 17:09:42 +00:00
rillig dd2389327b lint: in strict bool mode, allow 'a & b' in controlling expressions
Previously, the expression 'a & b' was only treated as bool if 'a' had
enum type.  This didn't cover cases in which bit masks were implemented
using integer types instead of enum sets.
2023-12-30 15:37:27 +00:00
rillig 7252c1d112 tests/lint: test '&' for non-enum types in strict bool mode 2023-12-30 15:18:57 +00:00
martin 21ef827d2a PR 57803: fix typo in test title. 2023-12-30 13:09:24 +00:00
andvar 79548a514e s/synax/syntax/ in test description. 2023-12-28 20:04:10 +00:00
rillig b4747d0de9 tests/indent: don't create an unneeded file 2023-12-17 10:02:09 +00:00
mlelstv d233f49979 mmap() fails for size == 0 with EINVAL unless the mapping is anonymous. 2023-12-11 09:26:08 +00:00
rillig 35fd37d4b4 tests/libcurses: require 3 digits in octal character escapes
Previously, the string literal "\0" had been interpreted as "0", which
would have made the backslash redundant.  The tests don't use this form.
2023-12-10 18:04:55 +00:00
rillig 97817c96ae indent: be strict about options from profile files
Previously, the "option" 'xdi0' was treated the same as '-xdi0'.
2023-12-10 17:45:35 +00:00
rillig 08fd84594d tests/libcurses: constify 2023-12-10 15:51:13 +00:00
rillig 2209bb4284 tests/libcurses: fix typo in comment 2023-12-10 15:42:29 +00:00
rillig d7c2af39e9 tests/indent: fix name of test case 2023-12-10 15:39:25 +00:00
rillig 960c22026a lint: allow querying for 'static' followed by non-'static' declaration 2023-12-10 15:29:38 +00:00
rillig de4a7516ed lint: clean up comments
No functional change.
2023-12-10 14:59:47 +00:00
riastradh 29fd213712 t_setrlimit: Narrow the scope of stack-protector warning suppression. 2023-12-07 16:54:44 +00:00
rillig 0fde876303 tests/indent: test compound expressions 2023-12-03 14:26:10 +00:00
rillig 9cb5ea81fb tests/libcurses: sync documentation with reality
Unknown escape sequences in string literals trigger an error, since
testlang_conf.l 1.22 from 2021-02-25.

The '\b' is recognized since testlang_conf.l 1.26 from 2021-11-15.
2023-12-03 09:42:36 +00:00
rillig 8a47554360 tests/lint: add more test cases for nonportable character comparison 2023-12-02 23:54:49 +00:00
christos 20b493dddb remove dup copy. 2023-12-02 16:18:17 +00:00
christos 6a63b824ad PR/57735: Jose Louis Duran: mtree -f file1 -f file2 does not consider type
changes.
(FreeBSD https://github.com/freebsd/freebsd-src/commit/\
    4f4b548b1d21ae16955b09f9b717524167a7d97e)
2023-12-02 13:23:59 +00:00
riastradh 20941a42e9 pthread: Don't adjust user-allocated stack addresses by guardsize.
PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-28 02:54:33 +00:00
riastradh a76ca770cc libpthread/t_stack: Fix format string for size_t.
Tested this on i386 since that had been crashing before, but i386
doesn't see %zu for unsigned int as a problem.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-28 00:27:05 +00:00
riastradh 2852ab885f libpthread/t_stack: Appease gcc12 maybe-uninitialized warning.
The jmp_buf is not, in fact, uninitialized at the point of use, but
it doesn't hurt to narrow the scope a bit to between when the jmp_buf
is initialized by setjmp, and when the signal handler might be called
after sigaction.

Noted by prlw1.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-27 22:18:29 +00:00
riastradh 1ce2050a8e libpthread/t_stack: Omit needless cast in previous.
Arose from an earlier draft of the change.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-27 22:17:41 +00:00
riastradh 73a871b293 libpthread/t_stack: Make this more robust to the guard size bug.
Make sure to allocate enough space for the thread's stack for a guard
even though there shouldn't be one, so that when we run the thread,
it doesn't start with the stack pointer pointing into someone else's
allocation (like malloc) causing stack frames to trash another data
structure -- or causing the user of that data structure to trash the
stack frames.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-27 22:15:08 +00:00
christos ecbffb52ab Don't use fmtcheck for strfmon format strings. It does not work. Fix a broken
test.
2023-11-27 19:45:36 +00:00
riastradh c73729f0bb t_dlinfo, t_rtld_r_debug: Audit ATF_REQUIRE/CHECK, sprinkle messages.
Make sure to use ATF_REQUIRE when the subsequent code doesn't work if
the check fails.
2023-11-24 17:40:20 +00:00
riastradh e441ef5517 rtld tests: Don't use RZ for dlinfo.
Use

	ATF_REQUIRE_EQ_MSG(dlinfo(...), 0, "dlinfo: %s", dlerror())

instead, in order to accurately report the error on failure.  RZ is
only for functions like pthread_create(3) that return zero on success
and errno(3) code on failure, but dlinfo returns -1 on failure and
sets dlerror() to report the nature of the error.
2023-11-24 17:40:09 +00:00
riastradh ef23f679e4 tests: Audit RZ abuse.
RZ succeeds if x is zero, and fails if x is nonzero, treating a
nonzero value as a error number as in errno(3) to print the message.

The following library routines instead return -1 on failure and set
errno to the error code:

fuse_opt_add_arg
fuse_opt_add_opt
fuse_opt_add_opt_escaped
fuse_opt_insert_arg
lseek
system

So use RL instead for those -- succeeds if x is zero, and fails if x
is -1.

This shouldn't make any tests newly fail or newly succeed -- the
functions in question only ever return 0 or -1 -- but if the tests
were already failing anywhere, they will now fail with meaningful
messages.

TBD: dlinfo, which isn't fit for RL or RZ since it reports errors via
dlerror() rather than errno.
2023-11-24 17:31:03 +00:00
christos e757b4ce33 t_setrlimit uses alloca now 2023-11-24 17:19:55 +00:00
riastradh 8f4b2a189f t_rnd: Nix trailing whitespace.
No functional change intended.
2023-11-24 16:36:23 +00:00
riastradh 290ca0f2a9 t_rnd: Fix misuse of RZ.
Not likely to matter, but in the unlikely event that rump_sys_close
fails, it will return -1 and set errno as RL expects, not return the
error code as RZ expects.
2023-11-24 16:35:51 +00:00
riastradh 5b36b4ea47 pthread: Add tests for pthread user stack allocation.
PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-24 16:21:17 +00:00
riastradh 6cfac959ea t_setrlimit: Fix typos in comments and messages.
No substantive change intended.  Suggested by rillig@.

PR kern/57711

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-22 02:20:34 +00:00
riastradh bf53af405a exec: Map noaccess part of stack with prot=NONE, maxprot=READ|WRITE.
This way, setrlimit(RLIMT_STACK) can grant READ|WRITE access when
increasing the stack size.

PR kern/57711

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-21 00:09:18 +00:00
riastradh 2fb69068d1 t_setrlimit: Verify changing RLIMIT_STACK affects access to stack.
PR kern/57711

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-20 13:05:17 +00:00
riastradh 8328a6ed14 t_fdrestart: Mark some tests no longer xfail.
Backing out ad's changes last month seemed to fix the symptoms
(although I'm pretty sure this logic is still broken, more to come).

PR kern/57659
2023-11-18 19:46:55 +00:00
christos 8cbc788f24 PR/57689: RVP: getcwd() not overridable with -D_FORTIFY_SOURCE 2023-11-10 23:03:25 +00:00
riastradh 1eb7667c84 t_fenv: Factor checks out of switch in checkrounding.
No functional change intended, just tidies up a bit.

PR port-mips/57680

XXX pullup-10
2023-11-06 13:48:12 +00:00
riastradh 519833e0d7 t_fenv: Use volatile intermediate to force rounding to double.
See comment for details about why this is necessary.

Should fix these tests on i386 (and perhaps m68k too).

PR port-mips/57680

XXX pullup-10
2023-11-06 13:48:00 +00:00
riastradh 8fde1c3f4c t_fenv: Improve diagnostics when rounding mode tests fail.
Print the correct input, and print the rounding mode for clarity so
you don't have to cross-reference it by line number.

PR port-mips/57680

XXX pullup-10
2023-11-05 21:13:06 +00:00
riastradh 40e521dfc3 t_fenv: Add #pragma STDC FENV_ACCESS ON and verify FLT_RADIX is 2.
Except gcc doesn't implement this pragma, so make it conditional.

And clang only supports it on some architectures, so just leave it
out for now with a comment about why.

PR port-mips/57680

XXX pullup-10
2023-11-05 16:28:05 +00:00
riastradh f6d88030b5 t_fenv: Verify rounding mode takes effect.
At least for addition operations, anyway.

Somewhat redundant with the test t_fe_round added by maya@ but this
gives two minimal pairs to easily diagnose exactly what the rounding
mode is when the wrong one was selected.

PR port-mips/57680

XXX pullup-10
2023-11-05 16:06:27 +00:00
riastradh f7171b7a20 t_fenv: Check FLT_ROUNDS whenever we touch the rounding mode.
PR port-mips/57680

XXX pullup-10
2023-11-05 15:28:17 +00:00
riastradh 1865a6485e t_fenv: Print wrong values if tests fail.
XXX pullup-10
2023-11-05 15:27:40 +00:00
yamaguchi 63162a40fe Added the test for vlan over l2tp 2023-11-02 09:50:50 +00:00
rillig 49e867d6b1 tests/lint: test GCC attributes after abstract function type 2023-10-22 21:30:32 +00:00
rillig 0fce8157b2 tests/indent: clean up comments 2023-10-22 21:03:08 +00:00
rin fa6a6a38f1 ifconfig/t_capabilities: s/if_capabilities/if_capenable/ in message 2023-10-18 08:52:46 +00:00
rin e782b7c6e7 ifconfig/t_capabilities: Skip unless run_unsafe is configured to yes
The test modifies if_capabilities for all available interfaces.
This is not a behavior we expect for normal ATF runs.

Similar tests modifying living network configurations are already
skipped by default. This is the last one remained for ifconfig(8).

Also, I'm not sure whether this is a test for ifconfig(8).

XXX
Pullup to netbsd-10 ASAP. No other branches are affected.
2023-10-18 08:25:14 +00:00
yamaguchi e8037d3f57 Update the test case for MTU of lag to adapt new behavior 2023-10-18 06:41:00 +00:00
rjs 1b17496e10 The t_fdrestart test requires rump. 2023-10-17 13:51:52 +00:00
yamaguchi ca0a5f7dd4 Make the lagg interface up before change its MTU
This change is related to PR kern/57650
2023-10-16 07:57:40 +00:00
riastradh 349eda5c97 t_fdrestart: Rework this to be a little more robust.
For the write test, need to make sure the pipe's buffer is full first
before the write that blocks, so that it doesn't return partial
progress rather than ERESTART if woken.
2023-10-15 15:18:17 +00:00
riastradh d37c22e105 t_fdrestart: Verify rump_sys_write failed second time around.
PR kern/57659
2023-10-15 14:30:51 +00:00
riastradh 5ba0017fa5 t_fdrestart: New test of closing fd with another thread in I/O on it.
Adapted from regress/sys/kern/dislodgefd.

PR kern/57659
2023-10-15 13:22:52 +00:00
christos 9a3e6516d0 PR/57633: Jose Luis Duran: Add strfmon tests from FreeBSD 2023-10-14 20:19:31 +00:00
blymn fc8a227a5a Update check files affected by a fix to addbyte.c in libcurses. 2023-10-05 06:15:58 +00:00
christos 0630eb1ffb Add testing for pad resetting (Jose Luis Duran) 2023-09-28 13:31:11 +00:00
knakahara 4743d3462c Update for sys/net/if_ipsec.c:r1.35 2023-09-27 08:48:01 +00:00
kre 5ae58755a4 Perform quoting of variable expansions, etc correctly. That includes
(some) removing of quotes from where they're useless (superstition).

This should be NFC for these tests, as the data being quoted doesn't
happen to require it, but depending upon the data not altering, or the
code not being copied to a different environment is unwise, when it is
so easy to simply do it correctly.

A few line wrapping and white space changes as well.

Nothing changed here is intended to alter the way that the tests run,
or results generated.
2023-09-26 12:15:44 +00:00
gson d9ed1423c3 Don't expect the net/carp/t_basic/carp_handover_ipv6_halt_nocarpdevip
and carp_handover_ipv6_ifdown_nocarpdevip test cases to fail.  At
least on the TNF i386 and amd64 testbeds, they pass more often than
not since the commit of src/sys/netinet/ip_carp.c 1.119 by mlelstv on
2023.04.07.06.44.08.
2023-09-19 11:55:14 +00:00
rillig 4f890ce92c lint: fix wording of diagnostics about 'C99 extension'
The term 'extension' means an extension to a C standard.  C99 by itself
is not an extension but a revision of the C standard.
2023-09-14 21:53:02 +00:00
rillig a479246e62 lint: mark unreachable function call arguments as used as well
Previously, in a '?:' expression with a constant condition, the branch
that is not taken was skipped but any identifiers in there were intended
to be marked as used.  In function call expressions, this only worked
for the last argument, as the PUSH operator is not a binary operator
(see ops.def).  Cover this case as well.
2023-09-12 22:01:05 +00:00
rillig f88aa15bf2 lint: mark symbols that are only used in untaken '?:' branch as used 2023-09-12 07:23:27 +00:00
rillig 41bc0f7db1 tests/lint: show that '?:' skips untaken branches early
This is probably done to avoid wrong warnings from branches that are
only taken on other platforms, but it also generates a wrong 'unused'
warning.
2023-09-12 06:51:02 +00:00
rillig 855fdcf693 tests/lint: allow lint libraries to be installed 2023-09-07 06:24:31 +00:00
rillig a5de335bf3 tests/lint: test case labels with out-of-bounds values 2023-09-07 06:17:35 +00:00
mrg 27c7635cf1 apply previous to just GCC. 2023-09-05 22:14:08 +00:00
riastradh d946f6431e certctl(8): Fix permissions on ca-certificates.crt bundle: 0644.
While here, write it atomically: write to .tmp first, then rename
when done; this way applications never see a partially-written bundle
at /etc/openssl/certs/ca-certificates.crt.
2023-09-05 12:32:30 +00:00
riastradh aa907e4708 certctl(8): Test permissions of ca-certificates.crt.
Inadvertently created 0600 instead of 0644 due to copying file
created by mktemp(1) with cp(1).
2023-09-05 12:31:33 +00:00
mrg bd4c4b4eb0 apply -Wno-maybe-uninitialized to chacha_sse2.c.
there's a clearly initialised memory region that is claimed as
being maybe uninitialised, and this test-build version of it
triggers it while the normal build doesn't.
2023-09-05 04:22:44 +00:00
riastradh f76ba7ffef certctl(8): Fix quoting and whitespace style in evilpath test.
No functional change intended.
2023-09-02 17:42:01 +00:00
riastradh 2572d76403 certctl(8): Fix some bugs with evil pathnames. 2023-09-02 17:41:43 +00:00
riastradh 4e4b90f7ff certctl(8): Test more evil pathnames. 2023-09-02 17:41:33 +00:00
riastradh 1cac5d57e4 certctl(8): Avoid clobbering prepopulated /etc/openssl/certs.
Also avoid clobbering some other edge cases like symlinks or
non-directories there.

This way, we have the following transitions on system updates:

- If /etc/openssl/certs is empty (as in default NetBSD<10 installs):
  quietly populated on rehash.

- If /etc/openssl/certs is nonempty (you've added things to it,
  e.g. by hand or with mozilla-rootcerts) and has never been managed
  by certctl(8): left alone on rehash, with an error message to
  explain what you need to do.

- If /etc/openssl/certs has been managed by certctl(8): quietly
  updated on rehash.

Note: This means current installations made since certctl(8) was
added will be treated like /etc/openssl/certs is nonempty and has
never been managed by certctl(8).  To work around this, you can just
delete /etc/openssl/certs and rerun `certctl rehash'.
2023-08-28 22:25:49 +00:00
riastradh 9189de7638 certctl(8): Test prepopulated /etc/openssl/certs.
This is the scenario when you have previously populated
/etc/openssl/certs manually, or with a package like mozilla-rootcerts
or mozilla-rootcerts-openssl, and you update to a version of NetBSD
with certctl(8).  In this case, certctl(8) should avoid destroying
your work.

While here, also test some related but less likely edge cases:

- nonexistent
- symlink
- regular file
2023-08-28 22:25:41 +00:00
riastradh 3d4f065740 certctl(8): Exit nonzero on missing certs.conf. 2023-08-28 22:25:32 +00:00
riastradh e1aab3dc32 certctl(8): Add xfail test for missing certs.conf.
Command should fail, i.e., exit with nonzero status, but it exits
with zero instead.
2023-08-28 22:25:21 +00:00
rillig dcb32fd76a lint: make diagnostics about ANSI C more international 2023-08-26 10:43:53 +00:00
rillig 92925e854e tests/usr.bin/error: add basic tests for several error message styles 2023-08-26 10:06:16 +00:00
riastradh 50a8b41245 certctl(8): New tool for managing OpenSSL CA certificates.
Same command-line syntax as FreeBSD, clearer semantics about which
parts are config and which parts are cache.
2023-08-26 05:27:13 +00:00
rin 1330871fbe t_ptrace_core_wait.h: Increment PC after trap, also for riscv
Fix *:core_dump_procinfo tests for riscv64.
2023-08-24 05:55:25 +00:00
rin d1f3632e87 riscv: tests/lib/csu: Fix typo in check_stack_alignment()
Now, all tests in tests/lib/csu successfully pass for riscv64.
2023-08-24 05:51:55 +00:00
rillig eb08e01b67 tests/compat/linux: fix typo in comment 2023-08-23 20:05:05 +00:00
christos a7f1bde315 Remove PROGDPLIBSSTATIC from ec and threads; dh still needs it because it
references internal symbols in libcrypto like ossl_dh_compute_key which
have been made static by the linker script (they are still visible in the
archive version).
2023-08-22 17:27:48 +00:00
rin 9b45ffed94 t_ipsec_{gif,l2tp}: Adjust for tcpdump 4.99.4
It does not longer output redundant `` (ipip-proto-4)'':
cba9b77a98

Now, these tests become passing again.

Thanks mlelstv@ for finding out upstream commit.
OK ozaki-r@
2023-08-22 05:40:50 +00:00
christos b7a2c5757f Tests for the compat_linux inotify framework from GSoC 2023 (Theodore Preduta) 2023-08-19 22:56:43 +00:00
christos 3a3e6e6861 Update link. We should also update the data... 2023-08-15 19:05:41 +00:00
riastradh 8a22324f3b vis(3): Fix one more buffer overrun in an edge case.
PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:48:52 +00:00
riastradh 6d340e9776 vis(3): Fix main part of PR lib/57573.
From Kyle Evans <kevans@FreeBSD.org>.

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:48:37 +00:00
riastradh ad713b59f2 vis(3) tests: Test another overflow edge case.
Related to PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:46:16 +00:00
riastradh 4d342ca518 vis(3) tests: Expand tests and diagnostic outputs on failure.
PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:45:03 +00:00
riastradh db2eb9a062 vis(3) tests: Add xfail test for encoding overflow.
From Kyle Evans <kevans@FreeBSD.org>.

PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:43:26 +00:00
rillig fdd1c40690 tests/lint: test parsing of preprocessing directives 2023-08-11 04:27:49 +00:00
riastradh 78e153c0eb workqueue(9) tests: Fix mistake in rev. 1.9.
Somehow, despite manually verifying a build/install/test of every
revision in my patch series, I managed to commit the wrong version of
the file for what became rev. 1.9, so the test was just broken when
it went in and remained broken in the commit where I fixed the real
bug and removed the xfail marker on the test.

PR kern/5757

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-10 22:20:20 +00:00
mrg 251ecc35b2 make this build with GCC 12.
there are some odd constructs here to trigger sanitizers.
2023-08-10 20:44:37 +00:00
riastradh 53a88a4133 workqueue(9): Avoid touching running work items in workqueue_wait.
As soon as the workqueue function has called, it is forbidden to
touch the struct work passed to it -- the function might free or
reuse the data structure it is embedded in.

So workqueue_wait is forbidden to search the queue for the batch of
running work items.  Instead, use a generation number which is odd
while the thread is processing a batch of work and even when not.

There's still a small optimization available with the struct work
pointer to wait for: if we find the work item in one of the per-CPU
_pending_ queues, then after we wait for a batch of work to complete
on that CPU, we don't need to wait for work on any other CPUs.

PR kern/57574

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-09 08:23:13 +00:00
riastradh f8e8b7bf19 workqueue(9) tests: Add test for PR kern/57574.
XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-09 08:23:02 +00:00
riastradh aab7c67520 workqueue(9) tests: Destroy struct work immediately on entry. 2023-08-09 08:22:53 +00:00
riastradh a8809f1847 workqueue(9) tests: Nix trailing whitespace. 2023-08-09 08:22:43 +00:00
riastradh c6ab813da9 tests/rump/rumpkern: Use PROGDPLIBS, not explicit -L/-l.
This way we relink the t_* test programs whenever changes under
tests/rump/kernspace change libkernspace.a.
2023-08-09 08:22:33 +00:00
rillig 7e8e260d9f lint: in -a mode, do not warn about integer conversions from 'int'
Since tree.c 1.552 from 2023-07-08, lint warned about integer
conversions from 'int' or 'unsigned int' to smaller integer types.  This
only affected 32-bit platforms where size_t is 'unsigned int' rather
than 'unsigned long', as on these platforms, the integer ranks of 'int'
and 'long' are the same, see INT_RANK in inittyp.c.

Discovered by lib/libkvm, which fails on i386 when lint generates any
warnings.
2023-08-08 20:15:10 +00:00
rillig 53d7accc5b tests/lint: test integer conversions on ilp32 int platforms 2023-08-08 19:57:23 +00:00
riastradh d3dc0d63ee t_cdb: No need for weird padding any more.
cdbw_output never needed it at runtime, and the declaration no longer
makes gcc angry about not having it.
2023-08-08 10:36:17 +00:00
mrg 832d47522a introduce new GCC 12 warning disables and use them in a few places
this introduces 4 new warning disable flags:

   CC_WNO_MISSING_TEMPLATE_KEYWORD
   CC_WNO_REGISTER
   CC_WNO_STRINGOP_OVERREAD
   CC_WNO_ARRAY_BOUNDS

and documents them in README.warnings.  of these, the string op
and array bounds are both problematic (real bugs) and also spurious
(not real bugs), and the other 2 are mostly temporary for older
3rd party code.

add some new uses of CC_WNO_STRINGOP_OVERFLOW.

fix m68k build for gallium and GCC 12.
2023-08-08 06:27:31 +00:00
mrg e58149cdf7 avoid uninitialised variable.
found by GCC 12.
2023-08-07 23:29:58 +00:00
rillig 26eb44f64d tests/lint: show that portable mode depends on PTRDIFF_TSPEC
Since 2023.07.08.12.45.43, lint warns in lib/libkvm on i386.
2023-08-07 22:30:38 +00:00
rin a65365b875 t_asan_global_buffer_overflow: Avoid ODR Violation for pic variants
Common symbol triggers ODR (One Definition Rule) Violation correctly,
instead of Global Buffer Overflow.

XXX
Add test for odr_violation.
2023-08-07 00:54:54 +00:00
rillig fe7ce87087 lint: since C99, a non-void function must return a value 2023-08-06 19:44:50 +00:00
rillig dca1e8c791 tests/lint: document how much of C99 lint already implements 2023-08-06 19:31:06 +00:00
riastradh cdd57aa330 tests/crypto/opencrypto: test_asymfeat requires privileges. 2023-08-05 13:29:57 +00:00
riastradh d493b3c627 tests/net/inpcb: Tests require root. 2023-08-05 13:25:26 +00:00
riastradh 5b1bee9cea tests/net/net/t_bind: IP_BINDANY and IPV6_BINDANY require root. 2023-08-05 13:22:49 +00:00
riastradh 23336793ae tests/lib/librumphijack: Avoid trying to run rpcbind as non-root.
Can probably make this work through rumphijack, but there's no sense
in even trying the test if we can't, so let's reduce the unprivileged
false alarms.
2023-08-05 13:13:37 +00:00
riastradh 1f0bb15ec8 tests/lib/libnvmm: Tests require privileges. 2023-08-05 13:05:14 +00:00
riastradh ea54f3e2ea t_nullmnt: Need privileges for mount.
(unless vfs.generic.usermount=1 but let's keep it simple)
2023-08-05 13:01:06 +00:00
riastradh 0351610f0a tests/include/t_paths: Test all paths, nonfatally.
This way a single failure doesn't suppress failure reports for all
the other paths to test.

Omit some needless blank lines while here.
2023-08-05 12:11:05 +00:00
riastradh 3f8fc68fb9 tests/include/t_paths: /dev/ksyms requires root. 2023-08-05 11:59:09 +00:00
rillig 8d2e8478af lint: implement __builtin_offsetof for the simplest cases
Cases not covered:
1. C99 allows designators in the offsetof macro.
2. For packed types, the offset is likely to be incorrect.
2023-08-05 10:13:39 +00:00
rillig 2d4c92c54f tests/lint: fix test for packed structs on 32-bit platforms 2023-08-05 10:00:59 +00:00
rillig 222dcfd4cf tests/lint: test C99 printf conversion specifiers in lint2 2023-08-05 09:44:18 +00:00
riastradh cf9621ed16 memfd(2): Run all tests; don't stop after the first failure. 2023-08-05 08:05:16 +00:00
rin 2c57825720 t_siginfo:sigfpe_int: Adjust for GCC12
Do not use constant 1 as numerator to raise integer division by zero.
GCC >= 12 optimizes (1 / i) into (abs(i) == 1 ? i : 0), even for -O0.
2023-08-04 03:31:13 +00:00
andvar 506971ff58 fix typos in comments and one definition, mainly s/sucket/socket/. 2023-08-03 20:45:49 +00:00
rillig 0448d06008 lint: make '_Static_assert' only available in C11 or C23 mode 2023-08-03 18:48:42 +00:00
nia e6ea867424 Revert addition of epoll to libc until discussion concludes 2023-08-03 12:24:46 +00:00
rin 2fd4746018 audiotest: Appease GCC 12.3.0 -Wmisleading-indentation
It does not matter whether this statement is a part of this if-then
block or not, anyway. No binary changes.
2023-08-03 08:36:38 +00:00
rin bfa63a7066 t_etfs: Skip large_blk for system with page size > 8192
Work around kernel freeze reported as PR kern/55658 for
powerpc/ibm4xx (16K pages)
2023-08-03 03:21:56 +00:00
rin a5ca3916c3 t_getrandom: Fix false positives for short read(2)
This only affects really slooooow machines, 68030 for me :)
2023-08-03 03:18:12 +00:00
rillig 5e813441c0 lint: fix handling of unnamed function parameters 2023-08-02 21:11:35 +00:00
rillig f2bab28745 lint: fix plural form in message 150 2023-08-02 18:57:54 +00:00
rillig 039b010016 lint: distinguish between arguments and parameters 2023-08-02 18:51:25 +00:00
rillig 9192ff1d13 lint: simplify handling of old-style arguments 2023-08-02 05:44:27 +00:00
gutteridge c14f999a4e t_pollts.c: fix typo in a description string (NFC) 2023-08-01 23:41:54 +00:00
andvar 1e7139f024 fix RCSIDs. 2023-08-01 20:09:12 +00:00
rillig b525fc25f4 tests/lint: test packed and in-parameter declarations 2023-08-01 19:52:15 +00:00
mrg 1115bcb541 cdbw_output()'s 3rd argument must be a 16-byte char array, so pad the
string literals passed to it with enough nuls to make this true.

found by GCC 12.
2023-08-01 07:57:17 +00:00
rillig 322d30b80f tests/lint: test symbol lookup in unnamed bit-field member declaration 2023-07-31 20:52:26 +00:00
rillig ce02e259a4 lint: fix assertion failure after unnamed bit-field member
Since 2023-07-15.
2023-07-31 20:31:58 +00:00
christos 2c545067c7 Add EPOLL_CLOEXEC (Theodore Preduta) 2023-07-30 18:31:13 +00:00
riastradh 3b7c09b692 ld.elf_so: Add some known-answer tests for hash functions.
Make sure the testing mechanism detects the traditional overflow bug.
2023-07-30 09:22:02 +00:00
rin 123e052909 t_memfd_create: Fix printf-like format by using %zu for size_t, and
%jd for off_t with cast to intmax_t, respectively.
2023-07-29 16:24:35 +00:00
christos d3ba7ba3a2 Add tests for t_memfd_create and fix bug found by tests 2023-07-29 12:16:34 +00:00
rillig ed9a7a8560 lint: condense code for ending a function
No functional change.
2023-07-29 07:49:14 +00:00
rillig 6383202121 tests/lint: test declarations in C11 and C23 2023-07-28 22:05:44 +00:00
christos d11110f473 Add epoll(2) from Theodore Preduta as part of GSoC 2023 2023-07-28 18:18:59 +00:00
rillig cbde550f0f lint: allow 'thread_local' to be combined with 'static' 2023-07-25 16:56:35 +00:00
rillig 5008d0bca1 lint: reword message about non-constant initializer 2023-07-21 06:02:07 +00:00
rillig 6d841877fb tests/lint: document an example of a non-constant initializer 2023-07-21 05:51:12 +00:00
mrg 7ab3f5c310 provide more things needed by new subr_prf.c. 2023-07-18 06:37:55 +00:00
rillig 1e05010e5d lint: each member declarator may have attributes, not only the last one 2023-07-15 21:47:35 +00:00
rillig c147c2e884 tests/lint: test GCC attributes in member declarations 2023-07-15 21:40:03 +00:00
rillig df9c24dec3 lint: allow 'extern' and 'thread_local' to be combined 2023-07-15 16:17:37 +00:00
rillig c68209d3ed tests/lint: test 'extern thread_local' storage classes
Seen in external/mpl/bind/dist/lib/isc/pthreads/include/isc/thread.h:32.
2023-07-15 16:11:32 +00:00
rillig 914dc1bf88 lint: fix member lookup after GCC statement expression 2023-07-15 14:54:31 +00:00
rillig 9a2539b9eb lint: fix use-after-free bug in GCC statement expressions 2023-07-15 13:51:36 +00:00
rillig ef4646fea8 tests/lint: demonstrate use-after-free in GCC statement expression 2023-07-15 12:24:57 +00:00
rillig 2ab89be182 tests/lint: document how to reliably crash lint1 after a parse error 2023-07-15 09:53:46 +00:00
rillig b956127314 lint: add debug logging for memory management and the symbol table 2023-07-15 09:40:36 +00:00
rillig 95638de25a lint: clean up comments, add a test for the '?:' operator 2023-07-14 08:53:52 +00:00
rillig b81e1a9edf tests/lint: test duplicate type qualifiers in pointer types 2023-07-13 22:44:10 +00:00
riastradh 07b9e924e1 t_bitops: Show the bad results on failure. 2023-07-13 20:39:24 +00:00
rillig 78e3dd62e3 lint: in C23 mode, recognize the keyword 'thread_local' 2023-07-13 20:30:21 +00:00
rillig fe2ba0d5e5 lint: _Thread_local is a storage class, not a type qualifier 2023-07-13 19:59:08 +00:00
rillig bc10e9be9d lint: reject _Noreturn if it occurs in invalid places
C11 introduced _Noreturn as a function-specifier, not as a type
attribute.  The latter may occur in more places.
2023-07-12 18:26:04 +00:00
rillig 5e96f60f79 tests/lint: add test for _Noreturn from C11 2023-07-12 18:13:39 +00:00
rillig 032c24b4d9 lint: update wording in diagnostic for C99 2023-07-11 20:54:23 +00:00
riastradh a41503c83d t_clock_gettime: Avoid signed/unsigned comparison. 2023-07-09 19:19:40 +00:00
rillig 62071d8c64 lint: in the warning about ordered enums, mention the affected type 2023-07-09 12:04:08 +00:00
rillig ea3322651c lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
2023-07-09 11:18:55 +00:00
rillig a194378b9e lint: clean up the wording of a few diagnostics 2023-07-09 11:01:27 +00:00
rillig 4a29af3e7e lint: remove redundant '#' after 'argument' in diagnostics 2023-07-09 10:42:07 +00:00
riastradh 42ba7a81e2 clock_gettime(2): Fix CLOCK_PROCESS/THREAD_CPUTIME_ID.
Use same calculation as getrusage, not some ad-hoc arithmetic of
internal scheduler parameters that are periodically rewound.

PR kern/57512

XXX pullup-8
XXX pullup-9
XXX pullup-10
2023-07-08 20:02:10 +00:00
rillig 486fcaa047 lint: warn about pointer casts between different kinds of types
Pointer casts from an integer type to a floating-point type and vice
versa get a 'maybe troublesome' warning now.  The previous assumption
that all types of the same bit-size are convertible may have been valid
from a technical point of view, but still such code should get more
attention.

The rules for struct and union types could be made more fine-grained
later, if the need arises.  To suppress this warning, it's always
possible to cast to an intermediate 'void *'.
2023-07-08 16:13:00 +00:00
riastradh d60bdbc1da t_timerfd: Sprinkle slightly more diagnostics.
Might help us to see if we're off by just a little bit (maybe a tiny
jitter between the hardclock timer and the monotonic clock), or if
something is seriously amiss when the timerfd_block test fails
sporadically.
2023-07-08 15:32:58 +00:00
rillig a03d49bac0 lint: do not use portable type sizes in integer constraints
This reverts the change from tree.c 1.547 from 2023-07-03.  Back then, I
didn't know that the actual value from a type's 'portable size in bits'
was not supposed to be used.
2023-07-08 15:26:25 +00:00
riastradh 3fe2e0724d t_clock_gettime: Add test for PR kern/57512. 2023-07-08 14:05:51 +00:00
rillig 1d389f0fa4 lint: warn about conversion from 128-bit to smaller integer types 2023-07-08 12:45:43 +00:00
rillig 5bb571bbdc tests/lint: demonstrate missing warning for converting int128_t 2023-07-08 12:42:11 +00:00
rillig 1d1794a80f tests/lint: fix a few ilp32 tests 2023-07-08 11:03:00 +00:00
rillig 223ac6e8ac tests/lint: automate accepting changed test results 2023-07-08 10:01:17 +00:00
rillig afb87394f6 tests/lint: only overwrite .exp files if the output actually changes 2023-07-08 08:02:45 +00:00
rillig e6298b924c lint: warn about function definitions without header declaration
The existing warning was only issued for function declarations, not for
function definitions.

The interesting change in the tests is in msg_351.c.  Many other tests
use non-static functions due to their syntactic brevity.  In these
tests, the warning is disabled individually, to allow new functions to
be added without generating warning 351.
2023-07-07 19:45:22 +00:00
rillig 06b8093259 lint: only skip 'unused' warnings after errors, not other warnings
Previously, in -w mode, any warning suppressed further 'unused'
warnings, even though there was no need to do that.  This can be seen in
the test gcc_attribute_var.c, where only the last unused variable from a
function was marked as unused, the others slipped through.

Fixed by counting the errors and the warnings separately and only
combining them if actually desired.
2023-07-07 06:03:31 +00:00
rillig 62962fdef2 tests/lint: test all combinations of {func,obj}_{decl,def}
For a non-static function definition that is not declared in a header,
lint doesn't currently warn.  The previous test didn't notice this.
2023-07-07 00:25:23 +00:00
rillig a9b749ce7a tests/lint: merge duplicate tests for C11 _Atomic 2023-07-07 00:20:39 +00:00
riastradh 7d87cccbb2 t_sig_backtrace: Flush stdout before writing to STDOUT_FILENO.
Avoids confusing ordering of output.
2023-07-06 20:44:55 +00:00
rillig bff65bdad9 tests/lint: ensure consistent preprocessor filenames in tests
The deviations often happen when copying or renaming tests.
2023-07-06 07:33:36 +00:00
riastradh d2876e0fc7 tests/libexec/ld.elf_so: Fix helper library makefiles.
1. Consolidate logic into a single helper.mk to reduce duplication.
2. Set NO* variables, not MK* variables which are reserved for user.
3. Avoid eager X!= in favour of lazy ${X:sh}.
4. Mark _g.a set list entries obsolete.  Never should've been built!

PR misc/57462
2023-07-05 22:42:46 +00:00
riastradh bf2cc18785 t_posix_memalign: Simplify.
No functional change intended.
2023-07-05 12:09:39 +00:00
riastradh ec5bc5eca5 t_posix_memalign: Fix this to reflect restriction lifted in C17. 2023-07-05 11:43:05 +00:00