From e618bf7ec514aaf4d76fd83319a97c7ab9796035 Mon Sep 17 00:00:00 2001 From: Chirantan Ekbote Date: Mon, 25 May 2020 18:30:24 +0900 Subject: sys_util: Make ioctl number method a const fn This allows us to define const variables that are the return value of the method, which we can then use in match statements. BUG=b:157189438 TEST=unit tests Change-Id: I2475c59bfd43ec9ec149a6b688bf680fa2361a0b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2214962 Tested-by: kokoro Reviewed-by: Dylan Reid Commit-Queue: Chirantan Ekbote --- sys_util/src/ioctl.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys_util/src/ioctl.rs') diff --git a/sys_util/src/ioctl.rs b/sys_util/src/ioctl.rs index f8c7604..3cf622b 100644 --- a/sys_util/src/ioctl.rs +++ b/sys_util/src/ioctl.rs @@ -23,13 +23,13 @@ macro_rules! ioctl_expr { macro_rules! ioctl_ioc_nr { ($name:ident, $dir:expr, $ty:expr, $nr:expr, $size:expr) => { #[allow(non_snake_case)] - pub fn $name() -> ::std::os::raw::c_ulong { + pub const fn $name() -> ::std::os::raw::c_ulong { $crate::ioctl_expr!($dir, $ty, $nr, $size) } }; ($name:ident, $dir:expr, $ty:expr, $nr:expr, $size:expr, $($v:ident),+) => { #[allow(non_snake_case)] - pub fn $name($($v: ::std::os::raw::c_uint),+) -> ::std::os::raw::c_ulong { + pub const fn $name($($v: ::std::os::raw::c_uint),+) -> ::std::os::raw::c_ulong { $crate::ioctl_expr!($dir, $ty, $nr, $size) } }; -- cgit 1.4.1