From aa79e826869a7fed8df6b4f7e7a7503565659f89 Mon Sep 17 00:00:00 2001 From: iximeow Date: Wed, 29 May 2019 00:07:31 -0700 Subject: fix some warnings and rdtsc/swapgs decode errors --- src/display.rs | 20 ++++++++------------ src/lib.rs | 15 ++++----------- 2 files changed, 12 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/display.rs b/src/display.rs index 76db507..dfddeca 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,13 +1,9 @@ extern crate yaxpeax_arch; extern crate termion; -use termion::color; - use std::fmt; -use std::hint::unreachable_unchecked; - -use yaxpeax_arch::{Arch, Colorize, ColorSettings, Decodable, LengthedInstruction, ShowContextual, YaxColors}; +use yaxpeax_arch::{Colorize, ColorSettings, ShowContextual, YaxColors}; use yaxpeax_arch::display::*; use ::{RegSpec, RegisterBank, Opcode, Operand, Instruction, Segment}; @@ -545,7 +541,7 @@ impl Colorize for Instruction { } impl ShowContextual], T> for Instruction { - fn contextualize(&self, colors: Option<&ColorSettings>, address: u64, context: Option<&[Option]>, out: &mut T) -> std::fmt::Result { + fn contextualize(&self, colors: Option<&ColorSettings>, _address: u64, context: Option<&[Option]>, out: &mut T) -> std::fmt::Result { if self.prefixes.lock { write!(out, "lock ")?; } @@ -561,7 +557,7 @@ impl ShowContextual], T> for Instructi ref x @ _ => { write!(out, " ")?; if let Some(prefix) = self.segment_override_for_op(0) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out)?; } @@ -580,14 +576,14 @@ impl ShowContextual], T> for Instructi x @ &Operand::Register(_) => { write!(out, ", ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } x @ _ => { write!(out, ", byte ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } @@ -606,14 +602,14 @@ impl ShowContextual], T> for Instructi x @ &Operand::Register(_) => { write!(out, ", ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } x @ _ => { write!(out, ", word ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } @@ -632,7 +628,7 @@ impl ShowContextual], T> for Instructi x @ _ => { write!(out, ", ")?; if let Some(prefix) = self.segment_override_for_op(1) { - write!(out, "{}:", prefix); + write!(out, "{}:", prefix)?; } x.colorize(colors, out) } diff --git a/src/lib.rs b/src/lib.rs index bc60dfd..ab67362 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,13 +10,9 @@ extern crate termion; mod display; -use termion::color; - -use std::fmt; - use std::hint::unreachable_unchecked; -use yaxpeax_arch::{Arch, ColorSettings, Decodable, LengthedInstruction}; +use yaxpeax_arch::{Arch, Decodable, LengthedInstruction}; #[cfg(feature="use-serde")] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] @@ -212,6 +208,7 @@ pub enum RegisterBank { X, Y, Z, // XMM, YMM, ZMM ST, MM, // ST, MM regs (x87, mmx) } +#[allow(non_camel_case_types)] #[cfg(not(feature="use-serde"))] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub enum RegisterBank { @@ -2586,11 +2583,11 @@ fn read_operands>( } else if r == 7 { if mod_bits == 0b11 { if m == 1 { - instruction.opcode == Opcode::SWAPGS; + instruction.opcode = Opcode::SWAPGS; instruction.operands = [Operand::Nothing, Operand::Nothing]; Ok(()) } else if m == 2 { - instruction.opcode == Opcode::RDTSCP; + instruction.opcode = Opcode::RDTSCP; instruction.operands = [Operand::Nothing, Operand::Nothing]; Ok(()) } else { @@ -2697,7 +2694,6 @@ fn read_operands>( } } OperandCode::Rq_Cq_0 => { - let opwidth = 8; let modrm = match bytes_iter.next() { Some(b) => b, None => return Err("Out of bytes".to_string()) @@ -2717,7 +2713,6 @@ fn read_operands>( Ok(()) } OperandCode::Rq_Dq_0 => { - let opwidth = 8; let modrm = match bytes_iter.next() { Some(b) => b, None => return Err("Out of bytes".to_string()) @@ -2736,7 +2731,6 @@ fn read_operands>( Ok(()) } OperandCode::Cq_Rq_0 => { - let opwidth = 8; let modrm = match bytes_iter.next() { Some(b) => b, None => return Err("Out of bytes".to_string()) @@ -2756,7 +2750,6 @@ fn read_operands>( Ok(()) } OperandCode::Dq_Rq_0 => { - let opwidth = 8; let modrm = match bytes_iter.next() { Some(b) => b, None => return Err("Out of bytes".to_string()) -- cgit v1.1