RFR: 8314114: Fix -Wconversion warnings in os code, primarily linux [v2]
Coleen Phillimore
coleenp at openjdk.org
Mon Aug 14 12:26:31 UTC 2023
On Mon, 14 Aug 2023 02:16:06 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> It doesn't. I got a Wconversion warning converting to int here. I wouldn't have changed it otherwise.
>>
>> src/hotspot/os/linux/os_linux.cpp:404:21: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
>> 404 | int rslt = syscall(SYS_gettid);
>> | ~~~~~~~^~~~~~~~~~~~
>
> I have to prove I'm not an idiot here :). This is from the Linux manpage:
>
> NAME
> syscall - indirect system call
>
> SYNOPSIS
> #define _GNU_SOURCE /* See feature_test_macros(7) */
> #include <unistd.h>
> #include <sys/syscall.h> /* For SYS_xxx definitions */
>
> int syscall(int number, ...);
>
> But yes the definition in unistd.h is `long int'.
>
> In platform specific code such as this, when a function returns a long then perhaps we should type the result variable as a long as well, rather than forcing to a 64-bit type?
We discussed purging 'long' from the code but since this is platform specific code, then we can use long here to match the type of syscall.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15229#discussion_r1293382554
More information about the hotspot-dev
mailing list