linux-stable/tools
John Stultz 19e8d8df9c 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 11:43:52 +02:00
..
accounting tools/accounting/getdelays.c: fix netlink attribute length 2020-04-13 10:48:08 +02:00
arch x86/bugs: Increase the x86 bugs vector size to two u32s 2023-08-08 19:56:37 +02:00
bpf bpftool: Fix bug for long instructions in program CFG dumps 2023-05-17 11:35:42 +02:00
build tools features: Add feature test to check if libbfd has buildid support 2023-09-23 11:00:05 +02:00
cgroup iocost_monitor: drop string wrap around numbers when outputting json 2020-06-22 09:31:01 +02:00
debugging
firewire
firmware
gpio tools: gpio-hammer: Avoid potential overflow in main 2020-10-01 13:17:47 +02:00
hv
iio tools: iio: replace seekdir() in iio_generic_buffer 2024-04-13 12:51:39 +02:00
include tools headers UAPI: Sync linux/perf_event.h with the kernel sources 2023-12-13 18:18:17 +01:00
io_uring tools/io_uring: fix compile breakage 2020-10-07 08:01:27 +02:00
kvm/kvm_stat
laptop
leds
lib libsubcmd: Fix memory leak in uniq() 2024-02-23 08:25:03 +01:00
memory-model
nfsd
objtool objtool: Add support for intra-function calls 2024-04-13 12:51:29 +02:00
pci
pcmcia
perf perf stat: Avoid metric-only segv 2024-03-26 18:22:20 -04:00
power tools/power turbostat: Fix Bzy_MHz documentation typo 2024-05-17 11:43:51 +02:00
scripts tools: Allow proper CC/CXX/... override with LLVM=1 in Makefile.include 2021-07-31 08:19:37 +02:00
spi
testing selftests: timers: Fix valid-adjtimex signed left-shift undefined behavior 2024-05-17 11:43:52 +02:00
thermal/tmon tools/thermal: Fix possible path truncations 2022-08-25 11:18:09 +02:00
time
usb usb: testusb: Fix for showing the connection speed 2021-10-09 14:39:49 +02:00
virtio tools/virtio: fix the vringh test for virtio ring changes 2023-02-22 12:50:34 +01:00
vm tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep" 2022-12-08 11:23:04 +01:00
wmi
Makefile