From 612ad0cb70b266fd9e6bfb387122e4fe4d0224bb Mon Sep 17 00:00:00 2001 From: LingMan <18294-LingMan@users.noreply.gitlab.freedesktop.org> Date: Thu, 3 Oct 2024 17:04:53 +0200 Subject: [PATCH] rusticl: Use C-string literals They got stabilized with Rust 1.77. Reviewed-by: Faith Ekstrand Reviewed-by: Karol Herbst Part-of: --- src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs | 5 +++-- src/gallium/frontends/rusticl/mesa/pipe/screen.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs b/src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs index a25c5189ded..193854322f6 100644 --- a/src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs +++ b/src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs @@ -7,6 +7,7 @@ use mesa_rust_gen::*; use mesa_rust_util::serialize::*; use mesa_rust_util::string::*; +use std::ffi::CStr; use std::ffi::CString; use std::fmt::Debug; use std::os::raw::c_char; @@ -14,7 +15,7 @@ use std::os::raw::c_void; use std::ptr; use std::slice; -const INPUT_STR: *const c_char = b"input.cl\0".as_ptr().cast(); +const INPUT_STR: &CStr = c"input.cl"; pub enum SpecConstant { None, @@ -140,7 +141,7 @@ impl SPIRVBin { headers: c_headers.as_ptr(), num_headers: c_headers.len() as u32, source: clc_named_value { - name: INPUT_STR, + name: INPUT_STR.as_ptr(), value: source.as_ptr(), }, args: c_args.as_ptr(), diff --git a/src/gallium/frontends/rusticl/mesa/pipe/screen.rs b/src/gallium/frontends/rusticl/mesa/pipe/screen.rs index 4f0d1590559..1ab3ad797c3 100644 --- a/src/gallium/frontends/rusticl/mesa/pipe/screen.rs +++ b/src/gallium/frontends/rusticl/mesa/pipe/screen.rs @@ -357,7 +357,7 @@ impl PipeScreen { }); if ptr.is_null() { // this string is good enough to pass the CTS - CStr::from_bytes_with_nul(b"v0000-01-01-00\0").unwrap() + c"v0000-01-01-00" } else { CStr::from_ptr(ptr) }