[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dcb1a59b-55a0-4a33-99a5-3800660b04b1@linuxfoundation.org>
Date: Thu, 11 Apr 2024 15:01:45 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: John Stultz <jstultz@...gle.com>, LKML <linux-kernel@...r.kernel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>, Stephen Boyd <sboyd@...nel.org>,
Anna-Maria Behnsen <anna-maria@...utronix.de>,
Frederic Weisbecker <frederic@...nel.org>, Shuah Khan <shuah@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>, Lee Jones <joneslee@...gle.com>,
Muhammad Usama Anjum <usama.anjum@...labora.com>,
linux-kselftest@...r.kernel.org, Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] selftests: timers: Fix valid-adjtimex signed left-shift
undefined behavior
On 4/9/24 14:22, John Stultz wrote:
> So, 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
> will trip 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,
> ~~~~^
> ...
>
> So fix our use of shifting negative values in the valid-adjtimex
> test case to use multiply by (1<<16) to avoid this.
>
> The patch also aligns the values a bit to make it look nicer.
>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Stephen Boyd <sboyd@...nel.org>
> Cc: Anna-Maria Behnsen <anna-maria@...utronix.de>
> Cc: Frederic Weisbecker <frederic@...nel.org>
> Cc: Shuah Khan <shuah@...nel.org>
> Cc: Nathan Chancellor <nathan@...nel.org>
> Cc: Nick Desaulniers <ndesaulniers@...gle.com>
> Cc: Lee Jones <joneslee@...gle.com>
> Cc: Muhammad Usama Anjum <usama.anjum@...labora.com>
> Cc: linux-kselftest@...r.kernel.org
> Reported-by: Lee Jones <joneslee@...gle.com>
> Reported-by: Muhammad Usama Anjum <usama.anjum@...labora.com>
> Link: https://lore.kernel.org/lkml/0c6d4f0d-2064-4444-986b-1d1ed782135f@collabora.com/
> Signed-off-by: John Stultz <jstultz@...gle.com>
> ---
Applied to linux-kselftest next for Linux6.10-rc1.
thanks,
-- Shuah
Powered by blists - more mailing lists