From 20c0466664a5ca6ac32c40e0cdeaef9afbed2c18 Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 29 Jul 2022 12:33:18 +0000 Subject: ripple/minitrace: match identifier style in macros Having macro identifiers match the "real" identifier style makes macro code markedly more readable. Change-Id: Ib675390cc04941ce782c75b2ee686709441081fc --- ripple/minitrace/src/main.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 7fa5ec7..523cc09 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -94,27 +94,27 @@ impl Process { } macro_rules! define_syscalls { - (enum $enum:ident { - $(fn $id:ident ( $($arg_id:ident : $arg_ty:ty),* ) -> $ret:ty = $nr:literal ;)* + (enum $SyscallEntry:ident { + $(fn $syscall:ident ( $($arg:ident : $Arg:ty),* ) -> $Ret:ty = $nr:literal ;)* }) => { #[derive(Debug, Copy, Clone)] #[allow(non_camel_case_types)] // TODO(edef): re-enable dead_code lint when we start fully interpreting syscall args #[allow(dead_code)] - enum $enum { - $($id { - $($arg_id : $arg_ty),* + enum $SyscallEntry { + $($syscall { + $($arg : $Arg),* }),* } - impl $enum { - fn from_regs(regs: libc::user_regs_struct) -> Result<$enum> { + impl $SyscallEntry { + fn from_regs(regs: libc::user_regs_struct) -> Result<$SyscallEntry> { Ok(match (regs.orig_rax, [regs.rdi, regs.rsi, regs.rdx, regs.r10, regs.r8, regs.r9]) { $( - ($nr, [$($arg_id),*, ..]) => $enum::$id { - $($arg_id: match SyscallArg::try_from_reg($arg_id) { + ($nr, [$($arg),*, ..]) => $SyscallEntry::$syscall { + $($arg: match SyscallArg::try_from_reg($arg) { Some(x) => x, - None => bail!("couldn't parse {}(2) {}: 0x{:08x}", stringify!($id), stringify!($arg_id), $arg_id) + None => bail!("couldn't parse {}(2) {}: 0x{:08x}", stringify!($syscall), stringify!($arg), $arg) }),* }, )* @@ -129,7 +129,7 @@ macro_rules! syscall_bitflags { ( struct $BitFlags:ident: $T:ty { $( - const $Flag:ident = $value:expr; + const $FLAG:ident = $value:expr; )* } @@ -138,7 +138,7 @@ macro_rules! syscall_bitflags { bitflags! { struct $BitFlags: $T { $( - const $Flag = $value; + const $FLAG = $value; )* } } -- cgit 1.4.1