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 B9F0543C21; Thu, 7 Mar 2024 21:57:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E2E842D7A; Thu, 7 Mar 2024 21:57:48 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id EC916402A3 for ; Thu, 7 Mar 2024 21:57:45 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2B4C220B74C0; Thu, 7 Mar 2024 12:57:45 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2B4C220B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1709845065; bh=2UvwP/MFtmv+hkxGxJYZtTiiNfab3CBo6xTz37H6FJk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gaAnA76cLDopPhPwTz6IQHOcuULKj/3EZZ4lVfdjuGSFVtF4YcgZbvaOX+7reDT1N jTNdOAhd0SNsm2V6LxE+SQPH69yOsEJS9BdNuBCg0f6fmyvfvwiAXqQCNaJxUKi95Y g7yxH5UVPowhxd0/s/TwgYFK+KoYmHF+3/w7y39A= Date: Thu, 7 Mar 2024 12:57:45 -0800 From: Tyler Retzlaff To: Bruce Richardson Cc: dev@dpdk.org, Dmitry Kozlyuk , Pallavi Kadam Subject: Re: [PATCH v2] eal/windows: resolve conversion and truncation warnings Message-ID: <20240307205745.GA2076@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1691009302-32551-1-git-send-email-roretzla@linux.microsoft.com> <1709836482-22576-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Thu, Mar 07, 2024 at 08:53:49PM +0000, Bruce Richardson wrote: > On Thu, Mar 07, 2024 at 10:34:42AM -0800, Tyler Retzlaff wrote: > > * 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; > > Just for readability, and the immediate visibility of errors, could this be > rewritten as (1000 * 1000 * 1000). That avoids us having to count the zeros > to know that the number is correct. > > BTW: is "int" still the best type to use for this value? Would it be better > as a #define? i think to save spot fixing i'm going to withdraw the series for now. i need to come back later and deal with warnings from MSVC more comprehensively anyway. thanks folks! > > /Bruce > > > 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 > >