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

Coleen Phillimore coleenp at openjdk.org
Sat Aug 12 13:42:01 UTC 2023


On Sat, 12 Aug 2023 06:15:09 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> checked_cast instantiates a template or two. I haven't measured code bloat.  It carries risk of asserting for odd inputs that used to be truncated.  In this case, it seems like a good place to have the assert.  In obvious places, it seems like noise.
>
> @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.

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

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


More information about the hotspot-dev mailing list