aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-02-19 12:20:44 -0800
committeriximeow <me@iximeow.net>2023-02-19 13:21:50 -0800
commit72f8f6677719a8ad7c8e61e4d629f47deef746cc (patch)
tree36ef932f5270bb7ca1f0c640e6fa36f9bb877614
parent78b40bb12a265d866b01547924defb10aec283a8 (diff)
deprecate `pub fn cs`, which is an intensely embarrassing bug of a function
unlike every other function to test if a particular selector is picked by prefixes, `Prefixes::cs` does not return bool, nor does it check the currently-selected prefix. instead, it modifies the decoded `Prefixes` to set the current prefix to `cs`. this has been a bug all the way since 0.0.1 was released. the function now does nothing, and is marked deprecated. in a future 2.x release, the function will be changed to return `bool` and be in-line with other segment selector-checking functions. in the mean time, a new `Prefixes::selects_cs()` does the correct thing. thank you to @meithecatte who pointed this out in https://github.com/iximeow/yaxpeax-x86/issues/28!
-rw-r--r--CHANGELOG4
-rw-r--r--src/long_mode/mod.rs5
-rw-r--r--src/protected_mode/mod.rs5
-rw-r--r--src/real_mode/mod.rs5
4 files changed, 16 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b4deece..585fcfa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,9 @@
## unreleased
* fix incorrect old yaxpeax-arch version selection for ffi crates
+* address incorrect behavior of `Prefixes::cs()`
+ * this "getter" would in fact set the selected segment to `cs`. it has never
+ actually returned a `bool`, like other selector-checking methods on
+ `Prefixes`.
## 1.1.5
* fix several typos across crate docs - thank you Bruce! (aka github user waywardmonkeys)
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs
index 6412afb..a89d673 100644
--- a/src/long_mode/mod.rs
+++ b/src/long_mode/mod.rs
@@ -4557,8 +4557,11 @@ impl Prefixes {
fn set_lock(&mut self) { self.bits |= 0x4 }
#[inline]
pub fn lock(&self) -> bool { self.bits & 0x4 == 4 }
+ #[deprecated(since = "0.0.1", note = "pub fn cs has never returned `bool` indicating the current selector is `cs`. use `selects_cs` for this purpose, until 2.x that will correct `pub fn cs`.")]
#[inline]
- pub fn cs(&mut self) { self.segment = Segment::CS }
+ pub fn cs(&mut self) {}
+ #[inline]
+ pub fn selects_cs(&self) -> bool { self.segment == Segment::CS }
#[inline]
pub fn ds(&self) -> bool { self.segment == Segment::DS }
#[inline]
diff --git a/src/protected_mode/mod.rs b/src/protected_mode/mod.rs
index 2993968..223c834 100644
--- a/src/protected_mode/mod.rs
+++ b/src/protected_mode/mod.rs
@@ -4514,8 +4514,11 @@ impl Prefixes {
fn set_lock(&mut self) { self.bits |= 0x4 }
#[inline]
pub fn lock(&self) -> bool { self.bits & 0x4 == 4 }
+ #[deprecated(since = "0.0.1", note = "pub fn cs has never returned `bool` indicating the current selector is `cs`. use `selects_cs` for this purpose, until 2.x that will correct `pub fn cs`.")]
#[inline]
- pub fn cs(&mut self) { self.segment = Segment::CS }
+ pub fn cs(&mut self) {}
+ #[inline]
+ pub fn selects_cs(&self) -> bool { self.segment == Segment::CS }
#[inline]
fn set_cs(&mut self) { self.segment = Segment::CS }
#[inline]
diff --git a/src/real_mode/mod.rs b/src/real_mode/mod.rs
index cad9499..1f6614e 100644
--- a/src/real_mode/mod.rs
+++ b/src/real_mode/mod.rs
@@ -4514,8 +4514,11 @@ impl Prefixes {
fn set_lock(&mut self) { self.bits |= 0x4 }
#[inline]
pub fn lock(&self) -> bool { self.bits & 0x4 == 4 }
+ #[deprecated(since = "0.0.1", note = "pub fn cs has never returned `bool` indicating the current selector is `cs`. use `selects_cs` for this purpose, until 2.x that will correct `pub fn cs`.")]
#[inline]
- pub fn cs(&mut self) { self.segment = Segment::CS }
+ pub fn cs(&mut self) {}
+ #[inline]
+ pub fn selects_cs(&self) -> bool { self.segment == Segment::CS }
#[inline]
fn set_cs(&mut self) { self.segment = Segment::CS }
#[inline]