RFR [XS] : 8239224: libproc_impl.c previous_thr may be used uninitialized warning

David Holmes david.holmes at oracle.com
Mon Feb 17 13:21:05 UTC 2020


Hi Matthias,

On 17/02/2020 11:10 pm, Baesken, Matthias wrote:
> Hello, please review this small fix.
> 
> When building a product build  with gcc7 on linux x86_64, and trying out different optimization options, I run into this error when
> optimizing for space (-Os)  :
> 
> 
> /open_jdk/jdk_5/jdk/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c: In function 'delete_thread_info':
> /open_jdk/jdk_5/jdk/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c:285:26: error: 'previous_thr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>         previous_thr->next = current_thr->next;
>         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
> 
> We should probably better initialize previous_thr to avoid this warning.
> 
> (it does not show up however with the default optimization options ).

Seems like a spurious warning to me but initializing to NULL is harmless.

I don't see the need for the NULL check however as previous_thr can't be 
NULL if we reach that part of the code.

Thanks,
David

> 
> Bug/webrev :
> 
> https://bugs.openjdk.java.net/browse/JDK-8239224
> 
> http://cr.openjdk.java.net/~mbaesken/webrevs/8239224.0/
> 
> 
> Thanks, Matthias
> 


More information about the hotspot-dev mailing list