Misleading name of `ioctl::BadOpcode`
This struct is to make RawOpcode in const level to satisfy CompileTimeOpcode bound. It is pretty common (and already used by rustix itself) to plug a generated constants, eg. from linux_raw_sys, into the ioctl::{Getter,Setter,Updater} interface. This practice uses less magic numbers in Rust code and should not be called "bad".
This issue was also mentioned in https://github.com/bytecodealliance/rustix/pull/861
The name
Badmade it seem like something I shouldn't be using, but taking the value by name fromlinux_raw_sysseems less error prone than looking up these components in a C header file and hard-coding them.
I'm not sure about the alternative names here, but here are some candidates:
-
LiteralOpcode: but it can accept any const expression, not necessarily literals. -
RawCompileTimeOpcode: really long to write. -
ConstOpcode: seems like synonym to the traitCompileTimeOpcode. -
RawOpcode: name collision with type aliasRawOpcode.
The name was taken from nix, which I assumed took it from some Linux kernel documentation. I have a memory of finding this document but I can't seem to find it now when I try to look for it.