Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1932533lqm; Fri, 3 May 2024 10:19:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9hTABduUDnAzTBcMDt4TAmpG7QTqXvifnZhH6jOh8gnaCWBDm7HZx8f/G5RgqC2otZvEWLYLR+NyLMWVFq0hdh2YIneGn69z4SaX5pA== X-Google-Smtp-Source: AGHT+IG4BCnWDbdPMVU0ughX+2yXdYB5wTum6j/Z/yMKDP6LwaWvJq6XQYzmN6xHpCjdEuy1DAzX X-Received: by 2002:a50:d4d5:0:b0:56c:5a49:730 with SMTP id e21-20020a50d4d5000000b0056c5a490730mr1893036edj.19.1714756783718; Fri, 03 May 2024 10:19:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714756783; cv=pass; d=google.com; s=arc-20160816; b=kDA1N8ozA4yQ/DdkwDLG3SyDQ2hh+favuE6cZhSjgEpMBdRN+pAF9UJW3O/oFqew48 PZCuN1+xHRm+HjqfTBazcbRuRb/YUA97FvQ1flPn69QpA6qLUUZxO/4zPfu2i98fNeaD vjx6UMB2arhSmJ2rDYhBRhEJXZ2znI91E9IIRNOkcpATyW1/9XtFVnjB67pjeHrKUzjy KvpbHWE0TaLNjqF72uLd1FQoMVtLwINqkpuAbklK2Y8BAIK9DIZDfRjcWU14IxqXpKd2 CkbOahg+zuJ9+3uJYedIqwmmY0AyrKnyOEueYRqBJ9vvEn6S0jk5r7gukvmkOhjcNsOt Cnfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=DV3hixoRF1gbXxdQWsIZAEC0l+fkBj8y3PUK3V7by1o=; fh=r3+uu7OUScFmnGsPJ+EoM+3XT6w/QR/bsDEz2/2X3eg=; b=NxBtQzkpqfQ5c8wI6A5mo4HbyZ9udxyph8zVMfqTmDJuGYljbGM9PgmgBy6dnYM3AP NKNpH3cRJF+2isSvdvrvRy8TxiGH1rXKNqV/Z6B6qvzvVhcYBu6/V4Bc58kss5mh43NN y2f1z7AMYB18N4/OCR7QTu6WzyjCLFni13r3P7X1lzTahct5Vgs3iLUKwqQZ+cW+WenA lOUixRuwsynVEiP4LUBwepx1Z5WRBsAJaUp6Lj+WWEqluNNAjOYSfK7yHRE/ItVf39gi 4zL/o9oI5Pq3rMl4wlMc4EA0hLONhMl17Yba2i/vx4RMgYGbG/k/FckPfO2NCiQfPFZr Ed3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JYGJZo0Y; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-167956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q22-20020a056402033600b00572ac3d6412si1770873edw.279.2024.05.03.10.19.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:19:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JYGJZo0Y; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-167956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 476301F22E0C for ; Fri, 3 May 2024 17:19:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1039B158215; Fri, 3 May 2024 17:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="JYGJZo0Y" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9651F1581FC; Fri, 3 May 2024 17:19:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714756749; cv=none; b=V6oKKlROdVOUyd//nR6N4uJNAzcYIFTB+Ib76Wn2AZbSSvjhvTeVZM6NH6c7+blK7e5c64oIljVIiLoWsF+waOeo8Dt8ETIm9KqpYJY8L68gWZhjd1da18XGGelidLAtwGGZyX4dxIkEgdMRKvO/x1md9rIKKUPm3hH5WFx8dNA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714756749; c=relaxed/simple; bh=zzz3iQzBIvo8oUdtkf8MNajD0FsADq1mc2by6A/+yhU=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=PhljdO6kXMfdAR2PvV9p2Y09AsuP4eplfmnWQXf9WySaAnGJbrgTCwr2yPk4fG4LFcbr7B6CcGewUo+7UiY+kwnxSRtK4wxGdyH8C1Xqx5p/gDQFpMNNM3efMxVg2Pxv91EfhlwNG7UbTS6qhEuSlk5H+vRWjBS0Kh+FvIlGvgk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=JYGJZo0Y; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1714756744; bh=zzz3iQzBIvo8oUdtkf8MNajD0FsADq1mc2by6A/+yhU=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=JYGJZo0YzUeV50Bvr4IIJXocSMwDl6JCLzxyx1OrR3Z2jZGsCHesxkyHS+xQENh0D /zN46oR4GzxL6xjYN2N8I2zYIIcCH51WrxMBJtGFP6yyNBmiD+1eD5OM4b0AHMlH3b ImqTVlJCFQTzkBvi2DfeaBb5NBV2oZVM//YvN8TL1jaKkbrE1hOCNQxuTzAR/QL5j0 S7mrI1HrbixRo2UsbFLwQf7PC1WK3acwBN1i4xvSmB3zMIGexuJMuusXxZCTsa5VTV lIAT8ezvcw4zf2ibWyOLEq+9oSEeto3dBJwgqksrmiVtvN9Qi5bE6PJ8VMl8gz6ydL z57Mu+bBWDC7Q== Received: from [10.193.1.1] (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 435B3378148F; Fri, 3 May 2024 17:19:00 +0000 (UTC) Message-ID: <99096ca9-f43b-471e-9a8f-cdd4adf93fba@collabora.com> Date: Fri, 3 May 2024 22:18:18 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , Andrei Vagin , Andrei Vagin , Dmitry Safonov , Thomas Gleixner , Valentin Obst , linux-kselftest@vger.kernel.org, LKML , llvm@lists.linux.dev Subject: Re: [PATCH] selftest/timerns: fix clang build failures for abs() calls To: John Hubbard , Shuah Khan References: <20240503032956.89290-1-jhubbard@nvidia.com> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <20240503032956.89290-1-jhubbard@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/3/24 8:29 AM, John Hubbard wrote: > 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=1 -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-2f9ed7d1c49f@valentinobst.de/ > > Signed-off-by: John Hubbard Thanks for fixing! Reviewed-by: Muhammad Usama Anjum > --- > 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/selftests/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 = 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); > } > return 0; > @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) > > for (i = 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 = 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/selftests/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 = 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/selftests/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 = 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 = 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 (%ld)\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 = 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 -- BR, Muhammad Usama Anjum