Commit Graph

6280 Commits

Author SHA1 Message Date
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
rillig 1603ef6585 tests/lint: spell platform identifiers for 'long double' consistently
The test file names don't have a hyphen, so the identifiers shouldn't
have one either.
2023-07-05 11:42:14 +00:00
rillig 581fbf1bfe tests/lint: add platform-specific tests for troublesome pointer casts 2023-07-05 11:36:56 +00:00
riastradh 50dbd23a19 t_posix_memalign: Expand test cases and properties.
- Test cartesian product of a sampling of sizes and a sampling of
  alignments.

- Verify all the edge cases I could find in posix_memalign and
  aligned_alloc, including failure modes.

- Test an unreasonably large (but aligned) allocation size.

- Use ATF_CHECK_* instead of ATF_REQUIRE_* so all failures will be
  reported, not just the first one.

- While here, build with -fno-builtin-aligned_alloc and with
  -fno-builtin-posix_memalign to make sure the compiler doesn't try
  any shenanigans.

XXX pullup-10
2023-07-04 15:06:36 +00:00
rillig 353545ac36 lint: consistently use portable type size in integer constraints
Since tree.c 1.546 from 2023-07-03, lint no longer warned about possible
loss of accuracy when converting from 'long' to 'int' on an ILP32
platform that uses 'unsigned long' for size_t, when run in portable mode
(-p), which is enabled by default in the NetBSD build.

The integer constraints avoid false-positive warnings by looking at the
actual values an expression can take.  The function can_represent is
guarded by a condition that uses the portable_size_in_bits, but then
internally used the opposite size_in_bits, which led to inconsistent
results.

The warning looks confusing though, as on an ILP32 platform, 'int' and
'long' have the same size and representation, therefore there cannot be
an actual loss of accuracy.  The warning may need to be reworded to
explicitly mention the portability mode, in which sizeof(int) is assumed
to be 3 instead of 4, to catch possible loss of accuracy on other
platforms.
2023-07-03 21:36:16 +00:00
rillig 2bb36c1110 tests/lint: move platform-specific query tests to separate files
This fixes the tests on 'unsigned char' platforms.

Thanks martin@ for the notification.
2023-07-03 15:29:42 +00:00
rillig e5eea854b3 tests/lint: clean up tests for C99 bool 2023-07-03 09:37:14 +00:00
rillig 10bd4ec804 lint: fix C11 mode to not allow C23 features (since yesterday) 2023-07-03 09:33:07 +00:00
rillig 4f51279e58 lint: rename uppercase QUAD to LLONG
No binary change.
2023-07-03 07:03:19 +00:00
rillig a615f06cd9 tests/lint: add C23 tests 2023-07-02 23:45:10 +00:00
rillig 29b0195f9b lint: add initial support for C23
Required by xsrc/external/mit/MesaLib.old, brw_eu_validate.c, which
initializes a struct using empty braces: 'return (struct string){};'.
2023-07-02 23:40:23 +00:00
rillig e16f398bf1 lint: allow empty statements in GCC statement expressions 2023-07-02 22:56:13 +00:00
rillig 6ab24c0b4d tests/lint: demonstrate empty statement in GCC statement expression
Seen in external/mit/xorg/lib/dri.old.
2023-07-02 22:50:18 +00:00
rillig ad4700f62b lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
2023-07-02 18:14:44 +00:00
rillig 600fe2a7c7 tests/lint: rework tests for type names 2023-07-01 20:57:37 +00:00
rillig c6d4ed97fd lint: clean up typos 2023-07-01 09:21:31 +00:00
rillig 130b20d8de lint: fix initialization of unnamed union member 2023-07-01 06:09:24 +00:00
rillig 91f591a176 tests/lint: test initializing an unnamed union 2023-06-30 22:27:47 +00:00
rillig c7c89cb5fa lint: clean up names related to declaration levels
The previous prefix 'DK_' (declaration level kind) had a conflict with
the 'DK_' (designator kind) in init.c, so change the prefix to 'DLK_'.
The new name for dinfo_t is decl_level, which is more expressive.

No functional change.
2023-06-30 21:39:54 +00:00
rillig e50dbdf451 lint: fix handling of unnamed struct/union members
The support for unnamed struct/union members that was added in decl.c
1.60 from 2015-10-13 was simple but wrong. It didn't cover initializers
of these structures and computed wrong sizes for structures containing
anonymous unions. At that time, the handling of initializers was broken
as well, it was fixed 6 years later in init.c 1.229 from 2021-12-22.

Real-life examples for code that lint couldn't handle are:

	* external/bsd/jemalloc/dist/src/jemalloc.c
	* external/mit/xorg/lib/dri.old/Makefile
2023-06-30 21:06:18 +00:00
rillig f6c9a3ff5c lint: clean up handling of declarations
No functional change.
2023-06-30 19:10:49 +00:00
rillig fc9c97fa4c tests/lint: extend tests for sizeof and alignof 2023-06-30 16:39:17 +00:00
rillig cb8166a1d1 lint: fix computation of bit-field width
When bit-fields in packed structs were added on 2009-10-02, lint assumed
that they would only use 'signed int' or 'unsigned int' as storage unit,
even though C99 also allows _Bool.

The cleanup commit for decl.c 1.225 from 2021-08-28 accidentally changed
the rounding mode for bit-field storage units from round-up to
round-down.
2023-06-30 15:19:09 +00:00
rillig 9ae9809bbf lint: make alignof(incomplete enum) an error 2023-06-30 09:26:03 +00:00
rillig bf86468d4c tests/lint: add more tests for sizeof, offsetof, alignof 2023-06-30 09:21:52 +00:00
rillig 082684fd88 lint: add query for assigning an integer 0 to a pointer 2023-06-30 08:45:22 +00:00
rillig 7aaf3a0593 tests/lint: extend test for sizeof and offsetof 2023-06-30 08:03:01 +00:00
rillig 10704a6fff tests/lint: demonstrate bugs in anonymous struct/union handling 2023-06-30 07:18:02 +00:00
rillig aca02333cc tests/lint: demonstrate wrong size calculation in anonymous union 2023-06-28 21:41:27 +00:00
rillig 87eefb9092 tests/lint: do not overwrite expected files that only differ in spaces 2023-06-28 20:51:31 +00:00
rillig 15b1ffda11 tests/lint: fix preprocessor line number validation
When running the tests via ATF, the filename was an absolute filename,
while the preprocessing line in the test file uses a relative filename.
These two didn't match.
2023-06-28 17:53:21 +00:00
rillig b6d101e5c9 tests/lint: demonstrate wrong handling of nested initializer
Seen in external/bsd/jemalloc/dist/src/jemalloc.c, init_lock.
2023-06-28 15:04:07 +00:00