Re: [PATCH v2] rust: ioctl: Add ioctl number manipulation functions

From: Asahi Lina
Date: Thu Mar 23 2023 - 08:24:46 EST


On 23/03/2023 21.18, Arnd Bergmann wrote:
On Thu, Mar 23, 2023, at 13:08, Asahi Lina wrote:
Changes in v2:
- Changed from assert!() to build_assert!() (static_assert!() can't work here)
...
+/// Build an ioctl number, analogous to the C macro of the same name.
+const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> u32 {
+ core::assert!(dir <= bindings::_IOC_DIRMASK);
+ core::assert!(ty <= bindings::_IOC_TYPEMASK);
+ core::assert!(nr <= bindings::_IOC_NRMASK);
+ core::assert!(size <= (bindings::_IOC_SIZEMASK as usize));

Just to make sure: did you actually change it according
to the changelog? It still looks like a runtime assertion
to me, but I don't really understand any rust.

Umm... I'm not sure what happened there.

Sorry, I'll resend it. I ran into some unrelated pain with bindgen versions while trying to compile-test this, and along the way I must have somehow dropped the actual v2 change...

~~ Lina