Re: [PATCH v10 7/8] rust: Add read_poll_timeout functions
From: FUJITA Tomonori <fujita.tomonori@gmail.com>
Date: 2025-02-14 04:05:40
Also in:
lkml, rust-for-linux
From: FUJITA Tomonori <fujita.tomonori@gmail.com>
Date: 2025-02-14 04:05:40
Also in:
lkml, rust-for-linux
On Sun, 9 Feb 2025 16:20:48 +0000 Gary Guo [off-list ref] wrote:
quoted
+fn might_sleep(loc: &Location<'_>) { + // SAFETY: FFI call. + unsafe { + crate::bindings::__might_sleep_precision( + loc.file().as_ptr().cast(), + loc.file().len() as i32, + loc.line() as i32, + ) + } +}One last Q: why isn't `might_sleep` marked as `track_caller` and then have `Location::caller` be called internally? It would make the API same as the C macro.
Equivalent to the C side __might_sleep(), not might_sleep(). To avoid confusion, it might be better to change the name of this function. The reason why __might_sleep() is used instead of might_sleep() is might_sleep() can't always be called. It was discussed in v2: https://lore.kernel.org/all/ZwPT7HZvG1aYONkQ@boqun-archlinux/ (local)
Also -- perhaps this function can be public (though I guess you'd need to put it in a new module).
Wouldn't it be better to keep it private until actual users appear?