RFR: 8375370: XRBackendNative.c reported variable uninitialized by clang23

Phil Race prr at openjdk.org
Thu Jan 15 18:11:12 UTC 2026


On Thu, 15 Jan 2026 07:36:05 GMT, SendaoYan <syan at openjdk.org> wrote:

> Hi all,
> 
> The local variable `pict_attr` in function `JNIEXPORT jint JNICALL Java_sun_java2d_xr_XRBackendNative_createPictureNative  (JNIEnv *env, jclass cls, jint drawable, jlong formatPtr)` reported variable uninitialized by clang23. This PR initial `pict_attr.repeat` to `RepeatNone` which will avoid compiler warning by clang23. This mofication references another `XRenderCreatePicture` call at  file [XRSurfaceData.c](https://github.com/openjdk/jdk/blob/master/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRSurfaceData.c#L72), they are all call the same function `XRenderCreatePicture`.

src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c line 342:

> 340: Java_sun_java2d_xr_XRBackendNative_createPictureNative
> 341:  (JNIEnv *env, jclass cls, jint drawable, jlong formatPtr) {
> 342:   XRenderPictureAttributes pict_attr;

This looks like an on-stack struct. It should be entirely initialized, not just one field, else it could be all sorts of random garbage.
Zeroing it out would be a good start.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29248#discussion_r2695438749


More information about the client-libs-dev mailing list