From c5a066bed453b93bbf7b1a975690671bbd219400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 21 Jun 2017 13:32:31 +0200 Subject: [PATCH] We need to pass by value and not by pointer for writing ioctls --- CHANGELOG.md | 3 +++ src/sys/ioctl/mod.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e44306ff6..c0fb9e2102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#614](https://github.com/nix-rust/nix/pull/614)) ### Changed +- Changed ioctl! write to take argument by value instead as pointer. + If you need a pointer as argument, use ioctl! write buf. + ([#626](https://github.com/nix-rust/nix/pull/626)) - Marked `sys::mman::{ mmap, munmap, madvise, munlock, msync }` as unsafe. ([#559](https://github.com/nix-rust/nix/pull/559)) - Minimum supported Rust version is now 1.13 diff --git a/src/sys/ioctl/mod.rs b/src/sys/ioctl/mod.rs index 0a95ec77af..48b3827bb8 100644 --- a/src/sys/ioctl/mod.rs +++ b/src/sys/ioctl/mod.rs @@ -158,7 +158,7 @@ macro_rules! ioctl { ); (write $name:ident with $ioty:expr, $nr:expr; $ty:ty) => ( pub unsafe fn $name(fd: $crate::sys::ioctl::libc::c_int, - val: *const $ty) + val: $ty) -> $crate::Result<$crate::sys::ioctl::libc::c_int> { convert_ioctl_res!($crate::sys::ioctl::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::libc::c_ulong, val)) }