v4l2: api: Fix ioctl() argument type mismatch. #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Annoyingly, the libc crate defines ioctl()'s argument types differently
on different platforms. On x86_64-unknown-linux-gnu, the existing code
works just fine. But, on aarch64-unknown-linux-musl (and Android
apparently), the libc crate instead says it takes an int, so we get a
compilation error.
We could work around this by writing the code differently for different
targets with #[cfg()]. But, that's less than ideal.
So, hack around this by using syscall() instead. It's a variadic
function, so we can just pass
whateverinto it. We're kind ofdepending on C's type conversion rules by doing so, but this turns out
to be kind of how e.g. glibc does it anyway.
At the end of the day: this should "just work" on all targets.
Signed-off-by: Axel Rasmussen axelrasmussen@google.com