From patchwork Wed Aug 2 20:48:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 129834 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B3C9442FBA; Wed, 2 Aug 2023 22:48:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2F5884021E; Wed, 2 Aug 2023 22:48:26 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 464C64021D for ; Wed, 2 Aug 2023 22:48:24 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 567B2238C43E; Wed, 2 Aug 2023 13:48:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 567B2238C43E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1691009303; bh=sMaWLpLfxLv1Uez5/k5Oj8rw4DyWf6d6BtZZhObH8Pw=; h=From:To:Cc:Subject:Date:From; b=YLw00JoeL9yC7+HHuvYbIYW+9oABUb0QBVJj8VIpauBSgERmmxXdz1CvlMf7YTREP WdetD4bSJVUvMsK6k9fRt15yIpRwkbNvufXB3NnnSyzNxiBC8i2b5ENo3k6sWzrOZ+ 8Au7CGUaIRLPG4xa6HoSyGZcQ8BHlR2wsKvsV/mk= From: Tyler Retzlaff To: dev@dpdk.org Cc: Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Tyler Retzlaff Subject: [PATCH] eal/windows: resolve conversion and truncation warnings Date: Wed, 2 Aug 2023 13:48:22 -0700 Message-Id: <1691009302-32551-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org * Initialize const int NS_PER_SEC with an integer literal instead of double thereby avoiding implicit conversion from double to int. * Cast the result of the expression assigned to timspec.tv_nsec to long. Windows builds generate integer truncation warning for this assignment since the result of the expression was 8 bytes (LONGLONG) but on Windows targets is 4 bytes. The value produced for the expression should safely fit in the long. Signed-off-by: Tyler Retzlaff Acked-by: Dmitry Kozlyuk --- lib/eal/windows/include/rte_os_shim.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/eal/windows/include/rte_os_shim.h b/lib/eal/windows/include/rte_os_shim.h index eda8113..19b12e9 100644 --- a/lib/eal/windows/include/rte_os_shim.h +++ b/lib/eal/windows/include/rte_os_shim.h @@ -87,7 +87,7 @@ static inline int rte_clock_gettime(clockid_t clock_id, struct timespec *tp) { - const int NS_PER_SEC = 1E9; + const int NS_PER_SEC = 1000000000; LARGE_INTEGER pf, pc; LONGLONG nsec; @@ -102,7 +102,7 @@ nsec = pc.QuadPart * NS_PER_SEC / pf.QuadPart; tp->tv_sec = nsec / NS_PER_SEC; - tp->tv_nsec = nsec - tp->tv_sec * NS_PER_SEC; + tp->tv_nsec = (long)(nsec - tp->tv_sec * NS_PER_SEC); return 0; default: return -1;