From 4cb3f4c389e120f444792bb091c1104b380f68d2 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 3 Jul 2024 14:51:05 +0200 Subject: [PATCH] [platform] launcher: making `vfprintf` hook return a number of processed bytes ..., lest JVM drop incomprehensible "Could not write log" message and shut up GitOrigin-RevId: cfe19e77c127e9b88e53b7f4ec82e1661bc4c6b1 --- native/XPlatLauncher/src/java.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/XPlatLauncher/src/java.rs b/native/XPlatLauncher/src/java.rs index ea87f94d3fd4..3bed5d22fe5b 100644 --- a/native/XPlatLauncher/src/java.rs +++ b/native/XPlatLauncher/src/java.rs @@ -47,11 +47,11 @@ extern "C" fn vfprintf_hook(fp: *const c_void, format: *const c_char, args: va_l None => unsafe { vfprintf(fp, format, args) }, Some(messages) => { let mut buffer = [0; 4096]; - let _ = unsafe { vsnprintf(buffer.as_mut_ptr(), buffer.len(), format, args) }; + let len = unsafe { vsnprintf(buffer.as_mut_ptr(), buffer.len(), format, args) }; let message = unsafe { CStr::from_ptr(buffer.as_ptr()) }.to_string_lossy().to_string(); debug!("[JVM] vfprintf_hook: {:?}", message); messages.push(message); - 0 // because nothing was actually printed + len } } }