Closed diwic closed 3 years ago
This seems like a reasonable addition. Could you add smoke test?
@jmesmon Just one design question. Read0 does two things different:
1) It returns a io::Result
rather than a c_int
2) It allocates a zeroed buffer and returns it
While 2) is something specific for some read calls, 1) is something that would be useful for essentially all ioctls, although the rest of them might return io::Result<()>
instead of io::Result<T>
. Any thoughts on how we parametrize that, like, should we add some new macro like ioctl_with_result!
, add a specific parameter like ioctl!(read io_result 'SOME_NAME' with ...)
, or something else?
That's a great point. It does seem like having some way to get io::Result<()>
for all ioctls could be useful. I'm not too attached to either option (new macro, or extra parameter), but given that we're currently covering everything with the 1 ioctl macro, it seems like using a new parameter (or a different first argument, like try_read
) could be good.
Do you have any thoughts on the upsides/downsides for the various choices?
@jmesmon Okay, I updated my patch. Feel free to merge it if you like it the way it is. I added try
versions for the most common variants.
@jmesmon Ping?
Ah, sorry about that. This looks fine.
bors r+
Build succeeded:
I've released this as ioctl-sys 0.7.0
I've also invited you to this repo and the associated crates on cargo.io so you don't need to wait on me for changes you'd like to make.
This version of the macro would start with a zeroed struct, call the ioctl, and return the struct if the ioctl succeeded, otherwise a proper error. Because that's usually what you want to do.
It's an untested draft, let me know what you think!