From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EB08843C12; Thu, 7 Mar 2024 19:34:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BCBE4402BA; Thu, 7 Mar 2024 19:34:45 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2145140272 for ; Thu, 7 Mar 2024 19:34:44 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 327A220B74C0; Thu, 7 Mar 2024 10:34:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 327A220B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1709836483; bh=IbY65/vOhIs+kM7KiLp3Sb9kp4ZmWMZTOJmHrmEPwVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pn2SFvgSvahgzCCBbKs79l5BbDeMTarypzpgWyukI5t1jUkzbIEau3nBUL/3gMGDt 56X9HXgHqLZE8lpXH/ifRt8Hm5Kr0bYdvYJzJRPQRXQSLpBDR86x7rrroGGYZNIuH9 ErfC+zluK+wEgp/seTNzc0A/aUlPl6GzPQabFm08= From: Tyler Retzlaff To: dev@dpdk.org Cc: Dmitry Kozlyuk , Pallavi Kadam , Tyler Retzlaff Subject: [PATCH v2] eal/windows: resolve conversion and truncation warnings Date: Thu, 7 Mar 2024 10:34:42 -0800 Message-Id: <1709836482-22576-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1691009302-32551-1-git-send-email-roretzla@linux.microsoft.com> References: <1691009302-32551-1-git-send-email-roretzla@linux.microsoft.com> 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 timespec.tv_nsec to long. Signed-off-by: Tyler Retzlaff Acked-by: Dmitry Kozlyuk --- v2: * update commit message to correct misspelled timspec -> timespec, remove remarks about casting to long they were unnecessary. 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; -- 1.8.3.1