Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1791496lqm; Fri, 3 May 2024 06:48:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWh8ho2XcVWBXxYoECS8eCzzUf4M+2T8eqi6LfchM6RPP4uVb2Nmwh4+iiHuEtUZOljRbGfLG+VjldVW3JMSPRipG4eh4wtyfu3EF+Lww== X-Google-Smtp-Source: AGHT+IGkQRTNUwS4cPjqMb/eBMa39smRiR38KQf4NoUimfSpvLjaQaLkr+KgBYX2WcEFy434HtzF X-Received: by 2002:a17:902:e84d:b0:1eb:a636:ecab with SMTP id t13-20020a170902e84d00b001eba636ecabmr2754396plg.34.1714744116490; Fri, 03 May 2024 06:48:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714744116; cv=pass; d=google.com; s=arc-20160816; b=dZ9g3LQZsoTzO3lEUuJOHDRoSAndQX8rIZLpGcuCj/zG+fbsqqBF9PmTcpswOmYuzR GuUby+dVDW5sw6OgOSmhOLRyYR3gH3ovjKWb7p+y3otQfSI2VYeYybVD0NOgXv+6g+Er CvKpiJti98iOOBt7LLOgM3+8NaBH42guowVvRLkrqC2Zhw7nM7af0NgjaplM4BQqPWaa GsAjQhNtz2dhTVha6rC/D0HvxrRq1wkw2Wr/7aLU08QHdTJNjXIXCGVVOu36hFQRzuK2 SSCFVU/aS1ZiwiSIiPTWWNf91GttuPYG6QxngWJEjSlI4BamQg3qVv2/M/bnPwJCE3Yj 4THw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=I6o8JjInWH3LKnqSsl6S6HrXQoEHLETqeq/r/V572dU=; fh=R+Eu9hvL4hM/+qQqeFC/o4305Tee0rsXhS2nvpD+BqE=; b=k3XgOWZraRW40wzOTPw/o6ulHrL9CC7TvSdyHk5KfFIKlgbdf1WKrRr7axfw/McLo6 0yrAijlOFJJvs19ikwIkWC6f9VPCmbQYgSroHQIdDiprIv8ugYu7q8XeEzBSQZRqoc8e XDp02jF95n/ZjNIH8Kllin8VQYBEYpz67Pgn9eDX1gmnWPtartS84vxrVAmUEzF1zFS7 jDgJG/HtrJDwyZ8E987iKWoSm8BXVAYqacC4u30HhdkcwH3ralv7+iDriODE9uPJ1VPc ebtrPuU8lIomfoii1baVQiy9gdypSGLJPfDGCBNic5nE1cPxo8k/7UF3pMxCCtoXXbpL o/Cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=Eo4oUO0N; arc=pass (i=1 spf=pass spfdomain=arista.com dkim=pass dkdomain=arista.com dmarc=pass fromdomain=arista.com); spf=pass (google.com: domain of linux-kernel+bounces-167723-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167723-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j17-20020a170902da9100b001e49428f32fsi3105901plx.252.2024.05.03.06.48.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 06:48:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167723-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=Eo4oUO0N; arc=pass (i=1 spf=pass spfdomain=arista.com dkim=pass dkdomain=arista.com dmarc=pass fromdomain=arista.com); spf=pass (google.com: domain of linux-kernel+bounces-167723-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167723-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 67225281E45 for ; Fri, 3 May 2024 13:48:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A39B9153584; Fri, 3 May 2024 13:48:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="Eo4oUO0N" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B411153BE3 for ; Fri, 3 May 2024 13:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714744094; cv=none; b=IF3+UwXI6Ky6buVy2VWl2WMtsPyU8W622VjOdzBa1CAgHgWHbgWK0/RGydxrBjD22ZBtwtmDWHA85893ZXcFFxTVoe3GnElWEuagB1FhOId/ESh5F4RWRJ8tAZpn8EzDYVj0PpefpNcfNk5fyFdqcojGV3Pyzk5tsQGEiv5OyEo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714744094; c=relaxed/simple; bh=ZtEDfOvwvxE7Fvlei3awx6n7b16lJ64hGqs3ri5Vvno=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=skEvtvTfloSBgg0x0iNmHukMWbFxvo6ZKvNWrkiwTWn2po5J0eA0UfGkZbxdCoycK+/pR91KBFVgxkh/EceDkBHF1tIpwRMFMy4+FX32rYgDw9UsSk2eVePD/sCxN7BIGKo/lYhHuMvsQcqIzQi8Rzh5n1cTYOjdG9bdP9sIHjM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=arista.com; spf=pass smtp.mailfrom=arista.com; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b=Eo4oUO0N; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=arista.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arista.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6f44b296e1fso606413b3a.3 for ; Fri, 03 May 2024 06:48:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1714744092; x=1715348892; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=I6o8JjInWH3LKnqSsl6S6HrXQoEHLETqeq/r/V572dU=; b=Eo4oUO0NyGT18aCFzFdFLe56ucL/AJueYCJUdmnHl9Nt23FCxhv5x37MaOUQ4mh6Rg 6rJn7CuSsD3GRMFq5Spa4vSs2Y6E/sn+whqdcgZfPtnfK0N0uG/rm4XIJzYVogyjq5cy T8gOz15Y0vP937ik8/MQs2ywKuHg/sWL6CQ/IJn0fQFnkVjd1NEBIL4WSTEDva/JujcI H6RvqEgEq7x/22Kzc1WfR+te5bXod4QDkYGax6eZR+WzdpL1b0kO6ZiyL8PeKwpKi6zH 36NuwY5Jj+qVik3dnrT6dxhciqxhsCWIz46r2bmQh9zOv3o9tINJDeTu0AbtuOMKxL0g tqkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714744092; x=1715348892; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I6o8JjInWH3LKnqSsl6S6HrXQoEHLETqeq/r/V572dU=; b=Lli10EEmYz3LtTAFeXZK4veSCL+a+b4R+lMkxP+5QDLaFHFyrF4LS/Bc4/FyAzUefH n5u5N8tqAtTu3CdbGiS6QqRCemu+i7jb6sU9QLb08UiZ+EjG/LwYTy7qKKrmLIpHbFO8 EZJyF4BsoJ4NcZDlV1FM9CQO/M1A3RkrpWNlFQwnPtba+GHxD3ETWGnRdmVQ74YB1j9B VCkNRM3figR8ZWQ1o9U+FhPH6LVy9mPc/PomQfYW83yksrOvLmAr9jCummfVOMh+Wt6H yWbWrRJqXwmaJT87LbV+YmDeEzpvSHNBReLLR+0uka2RXxyHV3MG0I0i8sAWAWby+prD 0ycw== X-Forwarded-Encrypted: i=1; AJvYcCXF81/WlvzlxwN5VSIxfgzrhmQEzXI5r9kDCNhF0TAv0Jptst62WQxhtGbPL5X/tUMbyXIs0QJDR7MlWbL4fCCORPvbcQOCma/anMGj X-Gm-Message-State: AOJu0YzBy2nvA4rIFSLQgtkr6mzVj7kAdFxvwAAWo1lm7Krxr22jztLD whH7OQpMEl2QDRoA+lJGcfc2w2IeFwtnie3JY/B4IoDwMbiT/BE6e0b0iErOAPFfGpp7hmAT+Wt tWbz9L/FIQyYkpy/hE0bx7YBY/OSL2VZ+SaCV X-Received: by 2002:a05:6a20:a7a9:b0:1ac:de42:bc5c with SMTP id bx41-20020a056a20a7a900b001acde42bc5cmr2278110pzb.42.1714744092194; Fri, 03 May 2024 06:48:12 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240503032956.89290-1-jhubbard@nvidia.com> In-Reply-To: <20240503032956.89290-1-jhubbard@nvidia.com> From: Dmitry Safonov Date: Fri, 3 May 2024 14:48:00 +0100 Message-ID: Subject: Re: [PATCH] selftest/timerns: fix clang build failures for abs() calls To: John Hubbard Cc: Shuah Khan , Andrei Vagin , Andrei Vagin , Thomas Gleixner , Valentin Obst , linux-kselftest@vger.kernel.org, LKML , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 3, 2024 at 4:30=E2=80=AFAM John Hubbard w= rote: > > First of all, in order to build with clang at all, one must first apply > Valentin Obst's build fix for LLVM [1]. Once that is done, then when > building with clang, via: > > make LLVM=3D1 -C tools/testing/selftests > > ...then clang warns about mismatches between the expected and required > integer length being supplied to abs(3). > > Fix this by using the correct variant of abs(3): labs(3) or llabs(3), in > these cases. > > [1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f= 9ed7d1c49f@valentinobst.de/ > > Signed-off-by: John Hubbard LGTM, even potentially fixes the testing post-2038. Reviewed-by: Dmitry Safonov > --- > tools/testing/selftests/timens/exec.c | 6 +++--- > tools/testing/selftests/timens/timer.c | 2 +- > tools/testing/selftests/timens/timerfd.c | 2 +- > tools/testing/selftests/timens/vfork_exec.c | 4 ++-- > 4 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/tools/testing/selftests/timens/exec.c b/tools/testing/selfte= sts/timens/exec.c > index e40dc5be2f66..d12ff955de0d 100644 > --- a/tools/testing/selftests/timens/exec.c > +++ b/tools/testing/selftests/timens/exec.c > @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) > > for (i =3D 0; i < 2; i++) { > _gettime(CLOCK_MONOTONIC, &tst, i); > - if (abs(tst.tv_sec - now.tv_sec) > 5) > + if (labs(tst.tv_sec - now.tv_sec) > 5) > return pr_fail("%ld %ld\n", now.tv_sec, t= st.tv_sec); > } > return 0; > @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) > > for (i =3D 0; i < 2; i++) { > _gettime(CLOCK_MONOTONIC, &tst, i); > - if (abs(tst.tv_sec - now.tv_sec) > 5) > + if (labs(tst.tv_sec - now.tv_sec) > 5) > return pr_fail("%ld %ld\n", > now.tv_sec, tst.tv_sec); > } > @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) > /* Check that a child process is in the new timens. */ > for (i =3D 0; i < 2; i++) { > _gettime(CLOCK_MONOTONIC, &tst, i); > - if (abs(tst.tv_sec - now.tv_sec - OFFSET) > 5) > + if (labs(tst.tv_sec - now.tv_sec - OFFSET) > 5) > return pr_fail("%ld %ld\n", > now.tv_sec + OFFSET, tst.= tv_sec); > } > diff --git a/tools/testing/selftests/timens/timer.c b/tools/testing/selft= ests/timens/timer.c > index 5e7f0051bd7b..5b939f59dfa4 100644 > --- a/tools/testing/selftests/timens/timer.c > +++ b/tools/testing/selftests/timens/timer.c > @@ -56,7 +56,7 @@ int run_test(int clockid, struct timespec now) > return pr_perror("timerfd_gettime"); > > elapsed =3D new_value.it_value.tv_sec; > - if (abs(elapsed - 3600) > 60) { > + if (llabs(elapsed - 3600) > 60) { > ksft_test_result_fail("clockid: %d elapsed: %lld\= n", > clockid, elapsed); > return 1; > diff --git a/tools/testing/selftests/timens/timerfd.c b/tools/testing/sel= ftests/timens/timerfd.c > index 9edd43d6b2c1..a4196bbd6e33 100644 > --- a/tools/testing/selftests/timens/timerfd.c > +++ b/tools/testing/selftests/timens/timerfd.c > @@ -61,7 +61,7 @@ int run_test(int clockid, struct timespec now) > return pr_perror("timerfd_gettime(%d)", clockid); > > elapsed =3D new_value.it_value.tv_sec; > - if (abs(elapsed - 3600) > 60) { > + if (llabs(elapsed - 3600) > 60) { > ksft_test_result_fail("clockid: %d elapsed: %lld\= n", > clockid, elapsed); > return 1; > diff --git a/tools/testing/selftests/timens/vfork_exec.c b/tools/testing/= selftests/timens/vfork_exec.c > index beb7614941fb..5b8907bf451d 100644 > --- a/tools/testing/selftests/timens/vfork_exec.c > +++ b/tools/testing/selftests/timens/vfork_exec.c > @@ -32,7 +32,7 @@ static void *tcheck(void *_args) > > for (i =3D 0; i < 2; i++) { > _gettime(CLOCK_MONOTONIC, &tst, i); > - if (abs(tst.tv_sec - now->tv_sec) > 5) { > + if (labs(tst.tv_sec - now->tv_sec) > 5) { > pr_fail("%s: in-thread: unexpected value: %ld (%l= d)\n", > args->tst_name, tst.tv_sec, now->tv_sec); > return (void *)1UL; > @@ -64,7 +64,7 @@ static int check(char *tst_name, struct timespec *now) > > for (i =3D 0; i < 2; i++) { > _gettime(CLOCK_MONOTONIC, &tst, i); > - if (abs(tst.tv_sec - now->tv_sec) > 5) > + if (labs(tst.tv_sec - now->tv_sec) > 5) > return pr_fail("%s: unexpected value: %ld (%ld)\n= ", > tst_name, tst.tv_sec, now->tv_sec= ); > } > > base-commit: f03359bca01bf4372cf2c118cd9a987a5951b1c8 > prerequisite-patch-id: b901ece2a5b78503e2fb5480f20e304d36a0ea27 > -- > 2.45.0 >