linux-stable/tools/testing
John Stultz dce583c5bd selftests: timers: Fix valid-adjtimex signed left-shift undefined behavior
[ Upstream commit 0763613621 ]

The struct adjtimex freq field takes a signed value who's units are in
shifted (<<16) parts-per-million.

Unfortunately for negative adjustments, the straightforward use of:

  freq = ppm << 16 trips undefined behavior warnings with clang:

valid-adjtimex.c:66:6: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        -499<<16,
        ~~~~^
valid-adjtimex.c:67:6: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        -450<<16,
        ~~~~^
..

Fix it by using a multiply by (1 << 16) instead of shifting negative values
in the valid-adjtimex test case. Align the values for better readability.

Reported-by: Lee Jones <joneslee@google.com>
Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Link: https://lore.kernel.org/r/20240409202222.2830476-1-jstultz@google.com
Link: https://lore.kernel.org/lkml/0c6d4f0d-2064-4444-986b-1d1ed782135f@collabora.com/
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-05-17 12:02:16 +02:00
..
crypto/chacha20-s390
cxl cxl: Add cxl_num_decoders_committed() usage to cxl_test 2024-01-10 17:17:02 +01:00
fault-injection
ktest ktest: force $buildonly = 1 for 'make_warnings_file' test type 2024-04-13 13:07:37 +02:00
kunit kunit: tool: fix parsing of test attributes 2024-02-05 20:14:15 +00:00
memblock memblock tests: fix warning ‘struct seq_file’ declared inside parameter list 2023-09-14 10:51:28 +03:00
nvdimm
radix-tree maple_tree: do not preallocate nodes for slot stores 2024-01-05 15:19:43 +01:00
scatterlist
selftests selftests: timers: Fix valid-adjtimex signed left-shift undefined behavior 2024-05-17 12:02:16 +02:00
vsock vsock/test: fix SEQPACKET message bounds test 2023-12-03 07:33:05 +01:00