[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <874j4jgqcw.fsf@prevas.dk>
Date: Thu, 07 Nov 2024 13:50:23 +0100
From: Rasmus Villemoes <ravi@...vas.dk>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: anna-maria@...utronix.de, frederic@...nel.org, tglx@...utronix.de,
jstultz@...gle.com, sboyd@...nel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, rust-for-linux@...r.kernel.org, andrew@...n.ch,
hkallweit1@...il.com, tmgross@...ch.edu, ojeda@...nel.org,
alex.gaynor@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
benno.lossin@...ton.me, a.hindborg@...sung.com, aliceryhl@...gle.com,
arnd@...db.de
Subject: Re: [PATCH v5 6/7] rust: Add read_poll_timeout functions
On Fri, Nov 01 2024, FUJITA Tomonori <fujita.tomonori@...il.com> wrote:
> For the proper debug info, readx_poll_timeout() and __might_sleep()
> are implemented as a macro. We could implement them as a normal
> function if there is a clean way to get a null-terminated string
> without allocation from core::panic::Location::file().
Would it be too much to hope for either a compiler flag or simply
default behaviour for having the backing, static store of the file!()
&str being guaranteed to be followed by a nul character? (Of course that
nul should not be counted in the slice's length). That would in general
increase interop with C code.
This is hardly the last place where Rust code would pass
Location::file() into C, and having to pass that as a (ptr,len) pair
always and updating the receiving C code to use %.*s seems like an
uphill battle, especially when the C code passes the const char* pointer
through a few layers before it is finally passed to a printf-like
function.
And creating the nul-terminated strings with c_str! needlessly doubles
the storage needed for the file names (unless the rust compiler is smart
enough to then re-use the c_str result for the backing store of the
file!() &str).
Rasmus
Powered by blists - more mailing lists