Skip to content

Commit bf96510

Browse files
committed
Unify argument names to generated ioctl functions
1 parent db7ef5f commit bf96510

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/sys/ioctl/mod.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
//! # use std::mem;
6969
//! # use nix::{Errno, libc, Result};
7070
//! # const SPI_IOC_MAGIC: u8 = 'k' as u8;
71-
//! pub unsafe fn spi_read_mode(fd: c_int, val: *mut u8) -> Result<c_int> {
72-
//! let res = libc::ioctl(fd, ior!(SPI_IOC_MAGIC, 1, mem::size_of::<u8>()), val);
71+
//! pub unsafe fn spi_read_mode(fd: c_int, data: *mut u8) -> Result<c_int> {
72+
//! let res = libc::ioctl(fd, ior!(SPI_IOC_MAGIC, 1, mem::size_of::<u8>()), data);
7373
//! Errno::result(res)
7474
//! }
7575
//! # fn main() {}
@@ -187,46 +187,47 @@ macro_rules! ioctl {
187187
);
188188
(read $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
189189
pub unsafe fn $name(fd: $crate::libc::c_int,
190-
val: *mut $ty)
190+
data: *mut $ty)
191191
-> $crate::Result<$crate::libc::c_int> {
192-
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
192+
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
193193
}
194194
);
195195
(write $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
196196
pub unsafe fn $name(fd: $crate::libc::c_int,
197-
val: $ty)
197+
data: $ty)
198198
-> $crate::Result<$crate::libc::c_int> {
199-
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
199+
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
200200
}
201201
);
202202
(readwrite $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
203203
pub unsafe fn $name(fd: $crate::libc::c_int,
204-
val: *mut $ty)
204+
data: *mut $ty)
205205
-> $crate::Result<$crate::libc::c_int> {
206-
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
206+
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
207207
}
208208
);
209209
(read buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
210210
pub unsafe fn $name(fd: $crate::libc::c_int,
211-
val: *mut $ty,
211+
data: *mut $ty,
212212
len: usize)
213213
-> $crate::Result<$crate::libc::c_int> {
214-
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
214+
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
215215
}
216216
);
217217
(write buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
218218
pub unsafe fn $name(fd: $crate::libc::c_int,
219-
val: *const $ty,
220-
len: usize) -> $crate::Result<$crate::libc::c_int> {
221-
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
219+
data: *const $ty,
220+
len: usize)
221+
-> $crate::Result<$crate::libc::c_int> {
222+
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
222223
}
223224
);
224225
(readwrite buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
225226
pub unsafe fn $name(fd: $crate::libc::c_int,
226-
val: *mut $ty,
227+
data: *mut $ty,
227228
len: usize)
228229
-> $crate::Result<$crate::libc::c_int> {
229-
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
230+
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
230231
}
231232
);
232233
}

0 commit comments

Comments
 (0)