On Thu, 29 Oct 2026 18:34:15 GMT, Phil Race <[email protected]> wrote:

>> While testing new MSVC warning flags, a number of unused but initialized 
>> variables in java.desktop have been found.
>> A lot of them can be removed. A few are needed for special build variants 
>> like (fast)debug only so they have to stay.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/java.desktop/windows/native/libawt/windows/awt_FileDialog.cpp line 76:
> 
>> 74:     int length = env->GetStringLength(filterDescription);
>> 75:     DASSERT(length + 1 < MAX_FILTER_STRING);
>> 76: #endif
> 
> how is this un-used ?

`int length` is only used in the DASSERT below, so it is DEBUG-only. Means 
unused in the product build.
Maybe we could just write
`DASSERT((env->GetStringLength(filterDescription)) + 1 < MAX_FILTER_STRING);`
so it is always in the debug/assert code?
Or if it is a valuable check, we could consider doing it in product too ?

> src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp line 1742:
> 
>> 1740:     }
>> 1741: 
>> 1742:     [[maybe_unused]] int technology = GetDeviceCaps(realHDC, 
>> TECHNOLOGY);
> 
> why did you not delete this one ?

It is in the DEBUG PRINTING below.
Thinking about it, it might be better to move down the line 1742 into the 
debug-printing, what do you think?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33495#discussion_r4421620591
PR Review Comment: https://git.openjdk.org/jdk/pull/33495#discussion_r4421634677

Reply via email to