Skip to content

Commit de726c4

Browse files
committed
Unify argument names to generated ioctl functions
1 parent c78506c commit de726c4

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/sys/ioctl/mod.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
//! # use std::mem;
7272
//! # use nix::{Errno, libc, Result};
7373
//! # const SPI_IOC_MAGIC: u8 = 'k' as u8;
74-
//! pub unsafe fn spi_read_mode(fd: c_int, val: *mut u8) -> Result<c_int> {
75-
//! let res = libc::ioctl(fd, ior!(SPI_IOC_MAGIC, 1, mem::size_of::<u8>()), val);
74+
//! pub unsafe fn spi_read_mode(fd: c_int, data: *mut u8) -> Result<c_int> {
75+
//! let res = libc::ioctl(fd, ior!(SPI_IOC_MAGIC, 1, mem::size_of::<u8>()), data);
7676
//! Errno::result(res)
7777
//! }
7878
//! # fn main() {}
@@ -92,7 +92,7 @@
9292
//! More examples on using `ioctl!` can be found in the [rust-spidev crate](https://github.com/rust-embedded/rust-spidev).
9393
//!
9494
//! ```text
95-
//! pub unsafe fn $NAME(fd: c_int, val: *mut u8, len: usize) -> Result<c_int>;
95+
//! pub unsafe fn $NAME(fd: c_int, data: *mut u8, len: usize) -> Result<c_int>;
9696
//! ```
9797
//!
9898
//! As mentioned earlier, there are many old `ioctl`s that do not use the newer method of
@@ -115,7 +115,7 @@
115115
//! The generated function has the same form as that generated by `read`:
116116
//!
117117
//! ```text
118-
//! pub unsafe fn tcgets(fd: c_int, val: *mut u8) -> Result<c_int>;
118+
//! pub unsafe fn tcgets(fd: c_int, data: *mut u8) -> Result<c_int>;
119119
//! ```
120120
//!
121121
//! There is also a `bad none` form for use with hard-coded `ioctl`s that do not transfer data.
@@ -189,46 +189,47 @@ macro_rules! ioctl {
189189
);
190190
(read $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
191191
pub unsafe fn $name(fd: $crate::libc::c_int,
192-
val: *mut $ty)
192+
data: *mut $ty)
193193
-> $crate::Result<$crate::libc::c_int> {
194-
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
194+
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
195195
}
196196
);
197197
(write $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
198198
pub unsafe fn $name(fd: $crate::libc::c_int,
199-
val: *const $ty)
199+
data: *const $ty)
200200
-> $crate::Result<$crate::libc::c_int> {
201-
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
201+
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
202202
}
203203
);
204204
(readwrite $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
205205
pub unsafe fn $name(fd: $crate::libc::c_int,
206-
val: *mut $ty)
206+
data: *mut $ty)
207207
-> $crate::Result<$crate::libc::c_int> {
208-
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
208+
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
209209
}
210210
);
211211
(read buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
212212
pub unsafe fn $name(fd: $crate::libc::c_int,
213-
val: *mut $ty,
213+
data: *mut $ty,
214214
len: usize)
215215
-> $crate::Result<$crate::libc::c_int> {
216-
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
216+
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
217217
}
218218
);
219219
(write buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
220220
pub unsafe fn $name(fd: $crate::libc::c_int,
221-
val: *const $ty,
222-
len: usize) -> $crate::Result<$crate::libc::c_int> {
223-
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
221+
data: *const $ty,
222+
len: usize)
223+
-> $crate::Result<$crate::libc::c_int> {
224+
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
224225
}
225226
);
226227
(readwrite buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
227228
pub unsafe fn $name(fd: $crate::libc::c_int,
228-
val: *mut $ty,
229+
data: *mut $ty,
229230
len: usize)
230231
-> $crate::Result<$crate::libc::c_int> {
231-
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
232+
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
232233
}
233234
);
234235
}

0 commit comments

Comments
 (0)