Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3329221pxb; Fri, 5 Nov 2021 13:47:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybKSqhT1wfdWqzbf/qgWzFsOUbxfvv6ETUUbBdR1Y4GwPyLOdQdk9iiy2rJlLb9Pe6W0vf X-Received: by 2002:a92:8742:: with SMTP id d2mr40607431ilm.128.1636145232970; Fri, 05 Nov 2021 13:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636145232; cv=none; d=google.com; s=arc-20160816; b=AQ1VRP+c0Vjb8/XHC+z3C12bIEowggFktaYxs+Vj5VdiNRvbUFXKHJLS6Xc8jcNxtI CGxaf0Imo0HuzCz26SjST26T8TrAuMqfeCDIOeXn+Omi0uLiFX2jgg9PcJ3E0E7uw6jk rsKaZfnRb3FoU4fqN6bob4zhfHFvND9ESdy4aNfaszl0PXWioQaJ2rqzeE90BYwocJIs 4S8T0Fkf4pMvvkfbQP0bm7WgI3+O4SdpzaiLOh4cG4JjQ2o3PDA12iMeXqkj6CYZXfxm Kh2VVPEo87IRQF1Cq+Rdokj/dUVSCLtCDmNL/jpN7u8izWY+bJJojoSTxPJ8khiUWpbO sdxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=senqiBJkxESggfPiWBCUi5fzLmZvRY+Wca6s+ykrVZE=; b=oxrskQumXqbtKXCa/QWieeLP9mINontaWTpPD/P+921r5/C0RwwhMEK0EoUTpb2tVD MR4PwDmyISjaz0lC7uZm5yNtnKkx0ZWX4gFGLTMaOUoQcCbmwJrDIcIcsXGBNUQTdAsq Vcx4udu4OiYytTObgF08Ihu+7nOragUAFPWN3gkCmBRpNNRrLaNVnkscVCuN4V+SFEI7 mbL2e5hrV/Y0UGlxl71I5rQdWa3ixSRnUSKPKs4/k6D2kX+uaHA0CTvhb4BtEuVzny8L pqA9e+91EfOrlCf0l9BqRG8gt6v9LevtYiPS75rqJFZZQlu82eQH5q2W3QwT70JxAfiH DFRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="tE/oV/4g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t34si17451998jal.104.2021.11.05.13.47.00; Fri, 05 Nov 2021 13:47:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="tE/oV/4g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233712AbhKEUrB (ORCPT + 99 others); Fri, 5 Nov 2021 16:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233197AbhKEUq7 (ORCPT ); Fri, 5 Nov 2021 16:46:59 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F31DC061714 for ; Fri, 5 Nov 2021 13:44:19 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id f3so21028327lfu.12 for ; Fri, 05 Nov 2021 13:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=senqiBJkxESggfPiWBCUi5fzLmZvRY+Wca6s+ykrVZE=; b=tE/oV/4g9EFoy+oty4gmADvSPhF9RtkrPCM8KYsx7S0ZT1o5JCnEvklXoCI9IxsqcM gxMTZRmXUvFzJEl/WJLI1x24ObCKPcy3VSYwr/7RGCco7gZ7o2rGHQ9fRMtJcaI+/a+c J66muvNcBHI/5CV205/pLwwEDs/to+O8pIu02srpXcku+Js2urLgtLi4nInfWxRMEEen W3kZEEEZiayiOotNfIGjhSssobGAjj/2yUKT9PKfKy6MgWilikRQ4VEzfNA96X5OU7B+ nmXQsZ2j0TFa8BpMuVlLXIU5pBR/m95t+sWiy+LyqN6jGystPHn97oWU5YMZ6LFT8X/L NntQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=senqiBJkxESggfPiWBCUi5fzLmZvRY+Wca6s+ykrVZE=; b=URP7YdpIh2IH+v1UFtXvx7wRTx+MIbJh/xKWReRdXS7bR5HJODV8VYKs4iPPxnXkjh lVpYhSlobg612ZWXzYSu3kcUppGNOUvFDN3ie0uDc7vbbbPHesCfODAgxa+73q0q8Sfo Ef/2bGJduu9CUTfb7TLOo/SKVOqHTOt+qevr/zfsuy4QcWOOGoeHa45VSKxxNwBLc/k0 +u200vb8r/gzi2PYqnfKVUWTzbTt20zGJVb0cUsMu8ROoogX8CSvLypQo8zEu6eAs9PS nqeEfCAL+5QQ+UMi9U+VEsKQzhLdiFobCIfUU63MZpvcwBJ2IVRbMtJ/kgyTeVNjONQS 6bqQ== X-Gm-Message-State: AOAM531hhGgOCDdFNgUW8R9B+HovgvK1ixCjlPsUKL2M+s8Fd4AeaORc /zMLmIiPQHkW1AfBuWvFdgMmcBRBSg/g6RPEDYierQ== X-Received: by 2002:a05:6512:228a:: with SMTP id f10mr55986163lfu.489.1636145057351; Fri, 05 Nov 2021 13:44:17 -0700 (PDT) MIME-Version: 1.0 References: <20211105163403.3330950-1-anders.roxell@linaro.org> In-Reply-To: <20211105163403.3330950-1-anders.roxell@linaro.org> From: Nick Desaulniers Date: Fri, 5 Nov 2021 13:44:06 -0700 Message-ID: Subject: Re: [PATCH] selftests: timers: use 'llabs()' over 'abs()' To: Anders Roxell Cc: shuah@kernel.org, tglx@linutronix.de, john.stultz@linaro.org, nathan@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 5, 2021 at 9:34 AM Anders Roxell wrote: > > When building selftests/timers with clang, the compiler warn about the > function abs() see below: > > posix_timers.c:69:6: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] > if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) { > ^ > posix_timers.c:69:6: note: use function 'llabs' instead > if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) { > ^~~ > llabs > > The note indicates what to do, Rework to use the function 'llabs()'. > > Signed-off-by: Anders Roxell Thanks for the patch! Reviewed-by: Nick Desaulniers I wonder why tools/testing/selftests/timers/adjtick.c redefines llabs when it already includes stdlib.h, and how that doesn't result in some kind of compiler diagnostic. > --- > tools/testing/selftests/timers/posix_timers.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c > index 337424c5c987..73fb27901a1d 100644 > --- a/tools/testing/selftests/timers/posix_timers.c > +++ b/tools/testing/selftests/timers/posix_timers.c > @@ -66,7 +66,7 @@ static int check_diff(struct timeval start, struct timeval end) > diff = end.tv_usec - start.tv_usec; > diff += (end.tv_sec - start.tv_sec) * USECS_PER_SEC; > > - if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) { > + if (llabs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) { > printf("Diff too high: %lld..", diff); > return -1; > } > -- > 2.33.0 > -- Thanks, ~Nick Desaulniers