Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert ioctl parameter type #318

Closed
wants to merge 1 commit into from
Closed

Conversation

gfreezy
Copy link

@gfreezy gfreezy commented Dec 14, 2019

ioctl type errors under musl.

error[E0308]: mismatched types
  --> /root/.cargo/git/checkouts/smoltcp-a623d622316b6317/d64d6b9/src/phy/sys/mod.rs:78:38
   |
78 |         let res = libc::ioctl(lower, cmd, ifreq as *mut ifreq);
   |                                      ^^^ expected `i32`, found `u64`
   |
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
   |
78 |         let res = libc::ioctl(lower, cmd.try_into().unwrap(), ifreq as *mut ifreq);
   |                                      ^^^^^^^^^^^^^^^^^^^^^^^

@crawford
Copy link
Contributor

Duplicate of #317, but since you’ve got compiler output, why use as _ instead of following the compiler’s suggestion?

@gfreezy
Copy link
Author

gfreezy commented Dec 14, 2019


error[E0308]: mismatched types
  --> src/phy/sys/mod.rs:78:38
   |
78 |         let res = libc::ioctl(lower, cmd as i32, ifreq as *mut ifreq);
   |                                      ^^^^^^^^^^ expected u64, found i32
help: you can convert an `i32` to `u64` and panic if the converted value wouldn't fit
   |
78 |         let res = libc::ioctl(lower, (cmd as i32).try_into().unwrap(), ifreq as *mut ifreq);
   |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

linux expect u64 while musl expect i32. So as _ is used.

@crawford
Copy link
Contributor

I meant let res = libc::ioctl(lower, cmd.try_into().unwrap(), ifreq as *mut ifreq); (to avoid using as altogether).

@whitequark
Copy link
Contributor

Closing as #317 is merged.

@whitequark whitequark closed this Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants