[PATCH] eal/windows: resolve conversion and truncation warnings
Tyler Retzlaff
roretzla at linux.microsoft.com
Thu Aug 3 00:41:30 CEST 2023
On Thu, Aug 03, 2023 at 01:29:00AM +0300, Dmitry Kozlyuk wrote:
> 2023-08-02 13:48 (UTC-0700), Tyler Retzlaff:
> > * 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.
>
> Typo: "timespec".
oops
>
> > 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.
>
> Probably "but **tv_nsec** on Windows targets is 4 bytes".
thanks i'll update the wording.
one thing that confuses me a little and this change won't break how the
code already works (just makes the cast redundant) is that for mingw
sizeof(long) is being reported as 8 bytes.
this is in spec relative to the C standard but it does leave me somewhat
concerned if struct timespec as defined in the windows headers crosses
an abi boundary.
have you ever noticed this? any thoughts on it?
>
> > The value produced for the expression should safely fit in the long.
> >
> > Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> > ---
> > lib/eal/windows/include/rte_os_shim.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
thanks!
More information about the dev
mailing list