RFR: 8314114: Fix -Wconversion warnings in os code, primarily linux [v2]

David Holmes dholmes at openjdk.org
Mon Aug 14 02:24:58 UTC 2023


On Sat, 12 Aug 2023 13:01:08 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> @coleenp: The only case where sysconf could be not a small positive integer is when it returns an error, -1, and checked_cast will not catch that since it still fits an int. 
>> 
>> Up to you, but I'd either leave this unchecked, or convert the parameter for set_processor_count to unsigned.
>> 
>> @dean-long:
>>> change func() to a template function
>> 
>> I hope we don't do that, that sounds terrible. I still have to find a modern IDE that can work well with all the template code we have. The more templates we use, the worse features like call graph display work in IDEs like CDT or CLion.
>
> I'm also not in favor of additional templates to hide our use of wrongly sized integers.  There's already enough time-consuming decoding in places and terrible error messages.  I'd rather the integers be the right size.
> I don't like tricks. I'm not opposed at all to direct C style casts where we know they fit.  Seems simplest.  I'll change this one.

I think checked_cast should be used when the variable is potentially unconstrained, but as Thomas confirms these sysconf calls are only ever going to return small integers.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15229#discussion_r1292915210


More information about the hotspot-dev mailing list