My refactor missed the fact that `native_platform` is static. Add the proper guard before the first detection method, as it might not be necessary, and only print the debug message when a detection was actually performed.
Reported-by: Grazvydas Ignotas <nota...@gmail.com> Fixes: 7adb9b094894a512c019 ("egl/display: remove unnecessary code and make it easier to read") Signed-off-by: Eric Engestrom <eric.engest...@imgtec.com> --- src/egl/main/egldisplay.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 2a1f02738d..3f7752f53d 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -180,11 +180,13 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay) _EGLPlatformType _eglGetNativePlatform(void *nativeDisplay) { - static _EGLPlatformType native_platform; - char *detection_method; + static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM; + char *detection_method = NULL; - native_platform = _eglGetNativePlatformFromEnv(); - detection_method = "environment overwrite"; + if (native_platform == _EGL_INVALID_PLATFORM) { + native_platform = _eglGetNativePlatformFromEnv(); + detection_method = "environment overwrite"; + } if (native_platform == _EGL_INVALID_PLATFORM) { native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay); @@ -196,8 +198,10 @@ _eglGetNativePlatform(void *nativeDisplay) detection_method = "build-time configuration"; } - _eglLog(_EGL_DEBUG, "Native platform type: %s (%s)", - egl_platforms[native_platform].name, detection_method); + if (detection_method != NULL) { + _eglLog(_EGL_DEBUG, "Native platform type: %s (%s)", + egl_platforms[native_platform].name, detection_method); + } return native_platform; } -- Cheers, Eric _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev