From patchwork Wed Jun 9 14:38:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 1489911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G0VBS4gtdz9s5R for ; Thu, 10 Jun 2021 00:39:58 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 25D563C7AE6 for ; Wed, 9 Jun 2021 16:39:56 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 172613C7A97 for ; Wed, 9 Jun 2021 16:39:55 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id B60101000183 for ; Wed, 9 Jun 2021 16:39:54 +0200 (CEST) Received: from 1.general.cascardo.us.vpn ([10.172.70.58] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lqzN3-0004yU-El; Wed, 09 Jun 2021 14:39:53 +0000 From: Thadeu Lima de Souza Cascardo To: ltp@lists.linux.it Date: Wed, 9 Jun 2021 11:38:49 -0300 Message-Id: <20210609143849.298147-1-cascardo@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH] common_timers: define NSEC_PER_SEC as long long to avoid overflow on 32-bit X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Po-Hsu Lin Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" When multiplying 30 with NSEC_PER_SEC, the result would overflow on 32-bit platforms, unless there was promotion to long long, which is what tst_ts_from_ns expects. futex_wake04, which uses that, would end up getting EINVAL when calling futex, because timespec_valid would fail, as tv_nsec would have an invalid value. After this change, futex_wake04 passes on i386. Reported-by: Po-Hsu Lin Suggested-by: Cyril Hrubis Signed-off-by: Thadeu Lima de Souza Cascardo --- include/lapi/common_timers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/lapi/common_timers.h b/include/lapi/common_timers.h index 8da3abec24b2..953741d73810 100644 --- a/include/lapi/common_timers.h +++ b/include/lapi/common_timers.h @@ -12,7 +12,7 @@ #include "lapi/posix_clocks.h" #ifndef NSEC_PER_SEC -#define NSEC_PER_SEC (1000000000L) +#define NSEC_PER_SEC (1000000000LL) #endif static const clock_t clock_list[] = {