Skip to content

Commit

Permalink
Fix misc typos and add typos to rust CI
Browse files Browse the repository at this point in the history
  • Loading branch information
emesare committed Jan 13, 2025
1 parent 449809f commit ab0607b
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 30 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ jobs:
uses: actions-rust-lang/rustfmt@v1
with:
manifest-path: ./rust/Cargo.toml

# Check spelling with typos
spelling:
name: typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Typo Check
uses: crate-ci/[email protected]
with:
files: ./rust
2 changes: 1 addition & 1 deletion plugins/pdb-ng/src/symbol_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use binaryninja::confidence::ConfMergable;
use binaryninja::confidence::ConfMergeable;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::mem;
use std::sync::OnceLock;
Expand Down
6 changes: 3 additions & 3 deletions rust/src/binaryview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,13 @@ pub trait BinaryViewExt: BinaryViewBase {
// TODO: Replace with BulkModify guard.
/// Start adding segments in bulk. Useful for adding large numbers of segments.
///
/// After calling this any call to [BinaryViewExt::add_segment] will be uncommited until a call to
/// After calling this any call to [BinaryViewExt::add_segment] will be uncommitted until a call to
/// [BinaryViewExt::end_bulk_add_segments]
///
/// If you wish to discard the uncommited segments you can call [BinaryViewExt::cancel_bulk_add_segments].
/// If you wish to discard the uncommitted segments you can call [BinaryViewExt::cancel_bulk_add_segments].
///
/// NOTE: This **must** be paired with a later call to [BinaryViewExt::end_bulk_add_segments] or
/// [BinaryViewExt::cancel_bulk_add_segments], otherwise segments added after this call will stay uncommited.
/// [BinaryViewExt::cancel_bulk_add_segments], otherwise segments added after this call will stay uncommitted.
fn begin_bulk_add_segments(&self) {
unsafe { BNBeginBulkAddSegments(self.as_ref().handle) }
}
Expand Down
10 changes: 5 additions & 5 deletions rust/src/confidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Conf<T> {
pub confidence: u8,
}

pub trait ConfMergable<T, O> {
pub trait ConfMergeable<T, O> {
type Result;
/// Merge two confidence types' values depending on whichever has higher confidence
/// In the event of a tie, the LHS (caller's) value is used.
Expand Down Expand Up @@ -57,7 +57,7 @@ impl<T> Conf<T> {
/// Returns best value or LHS on tie
///
/// `Conf<T>` + `Conf<T>` → `Conf<T>`
impl<T> ConfMergable<T, Conf<T>> for Conf<T> {
impl<T> ConfMergeable<T, Conf<T>> for Conf<T> {
type Result = Conf<T>;
fn merge(self, other: Conf<T>) -> Conf<T> {
if other.confidence > self.confidence {
Expand All @@ -71,7 +71,7 @@ impl<T> ConfMergable<T, Conf<T>> for Conf<T> {
/// Returns LHS if RHS is None
///
/// `Conf<T>` + `Option<Conf<T>>` → `Conf<T>`
impl<T> ConfMergable<T, Option<Conf<T>>> for Conf<T> {
impl<T> ConfMergeable<T, Option<Conf<T>>> for Conf<T> {
type Result = Conf<T>;
fn merge(self, other: Option<Conf<T>>) -> Conf<T> {
match other {
Expand All @@ -84,7 +84,7 @@ impl<T> ConfMergable<T, Option<Conf<T>>> for Conf<T> {
/// Returns RHS if LHS is None
///
/// `Option<Conf<T>>` + `Conf<T>` → `Conf<T>`
impl<T> ConfMergable<T, Conf<T>> for Option<Conf<T>> {
impl<T> ConfMergeable<T, Conf<T>> for Option<Conf<T>> {
type Result = Conf<T>;
fn merge(self, other: Conf<T>) -> Conf<T> {
match self {
Expand All @@ -97,7 +97,7 @@ impl<T> ConfMergable<T, Conf<T>> for Option<Conf<T>> {
/// Returns best non-None value or None
///
/// `Option<Conf<T>>` + `Option<Conf<T>>` → `Option<Conf<T>>`
impl<T> ConfMergable<T, Option<Conf<T>>> for Option<Conf<T>> {
impl<T> ConfMergeable<T, Option<Conf<T>>> for Option<Conf<T>> {
type Result = Option<Conf<T>>;
fn merge(self, other: Option<Conf<T>>) -> Option<Conf<T>> {
match (self, other) {
Expand Down
4 changes: 2 additions & 2 deletions rust/src/custombinaryview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl<'a, T: CustomBinaryViewType> CustomViewBuilder<'a, T> {
///
/// The `BinaryView` argument passed to the constructor function is the object that is expected
/// to be returned by the `AsRef<BinaryView>` implementation required by the `BinaryViewBase` trait.
/// TODO FIXME welp this is broke going to need 2 init callbacks
/// TODO FIXME whelp this is broke going to need 2 init callbacks
pub fn create<V>(self, parent: &BinaryView, view_args: V::Args) -> Result<CustomView<'a>>
where
V: CustomBinaryView,
Expand Down Expand Up @@ -545,7 +545,7 @@ impl<'a, T: CustomBinaryViewType> CustomViewBuilder<'a, T> {
// prohibited, so an API contract was violated in order to get here.
//
// if we're here, it's too late to do anything about it, though we can at least not
// run the destructor on the custom view since that memory is unitialized.
// run the destructor on the custom view since that memory is uninitialized.
log::error!(
"BinaryViewBase::freeObject called on partially initialized object! crash imminent!"
);
Expand Down
6 changes: 3 additions & 3 deletions rust/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,7 @@ impl Function {
unsafe { Array::new(vars, count, ()) }
}

/// Merge one or more varibles in `sources` into the `target` variable. All
/// Merge one or more variables in `sources` into the `target` variable. All
/// variable accesses to the variables in `sources` will be rewritten to use `target`.
///
/// * `target` - target variable
Expand Down Expand Up @@ -2058,7 +2058,7 @@ impl Function {
}
}

/// Splits a varible at the definition site. The given `var` must be the
/// Splits a variable at the definition site. The given `var` must be the
/// variable unique to the definition and should be obtained by using
/// [crate::mlil::MediumLevelILInstruction::get_split_var_for_definition] at the definition site.
///
Expand All @@ -2081,7 +2081,7 @@ impl Function {
unsafe { BNSplitVariable(self.handle, &raw_var) }
}

/// Undoes varible splitting performed with [Function::split_variable]. The given `var`
/// Undoes variable splitting performed with [Function::split_variable]. The given `var`
/// must be the variable unique to the definition and should be obtained by using
/// [crate::mlil::MediumLevelILInstruction::get_split_var_for_definition] at the definition site.
///
Expand Down
2 changes: 1 addition & 1 deletion rust/src/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl FormInputBuilder {
}

/// Form Field: Vertical spacing
pub fn seperator_field(mut self) -> Self {
pub fn separator_field(mut self) -> Self {
let mut result = unsafe { std::mem::zeroed::<BNFormInputField>() };
result.type_ = BNFormInputFieldType::SeparatorFormField;
result.hasDefault = false;
Expand Down
2 changes: 1 addition & 1 deletion rust/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ impl Project {
/// }
/// }
/// ```
// NOTE mut is used here, so only one lock can be aquired at once
// NOTE mut is used here, so only one lock can be acquired at once
pub fn bulk_operation(&mut self) -> Result<ProjectBulkOperationLock, ()> {
Ok(ProjectBulkOperationLock::lock(self))
}
Expand Down
2 changes: 1 addition & 1 deletion rust/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Symbol {
unsafe { BNIsSymbolAutoDefined(self.handle) }
}

/// Wether this symbol has external linkage
/// Whether this symbol has external linkage
pub fn external(&self) -> bool {
self.binding() == Binding::Weak || self.binding() == Binding::Global
}
Expand Down
2 changes: 1 addition & 1 deletion rust/src/typeprinter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ pub trait TypePrinter {
) -> Option<Vec<InstructionTextToken>>;

/// In a single-line text representation of a type, generate the tokens
/// that should be printed after the type's name. Returns a ist of text
/// that should be printed after the type's name. Returns a list of text
/// tokens representing the type
///
/// * `type_` - Type to print
Expand Down
24 changes: 12 additions & 12 deletions rust/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ impl Debug for NamedTypeReference {
#[derive(Default, Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
pub struct QualifiedName {
// TODO: Make this Option<String> where default is "::".
pub seperator: String,
pub separator: String,
pub items: Vec<String>,
}

Expand All @@ -1956,8 +1956,8 @@ impl QualifiedName {
.iter()
.filter_map(|&raw_name| raw_to_string(raw_name as *const _))
.collect();
let seperator = raw_to_string(value.join).unwrap();
Self { items, seperator }
let separator = raw_to_string(value.join).unwrap();
Self { items, separator }
}

pub(crate) fn from_owned_raw(value: BNQualifiedName) -> Self {
Expand All @@ -1967,7 +1967,7 @@ impl QualifiedName {
}

pub fn into_raw(value: Self) -> BNQualifiedName {
let bn_join = BnString::new(&value.seperator);
let bn_join = BnString::new(&value.separator);
BNQualifiedName {
// NOTE: Leaking string list must be freed by core or us!
name: strings_to_string_list(&value.items),
Expand All @@ -1983,17 +1983,17 @@ impl QualifiedName {
}

pub fn new(items: Vec<String>) -> Self {
Self::new_with_seperator(items, "::".to_string())
Self::new_with_separator(items, "::".to_string())
}

pub fn new_with_seperator(items: Vec<String>, seperator: String) -> Self {
Self { items, seperator }
pub fn new_with_separator(items: Vec<String>, separator: String) -> Self {
Self { items, separator }
}

pub fn with_item(&self, item: impl Into<String>) -> Self {
let mut items = self.items.clone();
items.push(item.into());
Self::new_with_seperator(items, self.seperator.clone())
Self::new_with_separator(items, self.separator.clone())
}

pub fn push(&mut self, item: String) {
Expand All @@ -2014,7 +2014,7 @@ impl QualifiedName {
self.items.split_last().map(|(a, b)| {
(
a.to_owned(),
QualifiedName::new_with_seperator(b.to_vec(), self.seperator.clone()),
QualifiedName::new_with_separator(b.to_vec(), self.separator.clone()),
)
})
}
Expand Down Expand Up @@ -2042,7 +2042,7 @@ impl QualifiedName {
.iter()
.map(|item| item.replace(from, to))
.collect(),
seperator: self.seperator.clone(),
separator: self.separator.clone(),
}
}

Expand Down Expand Up @@ -2074,7 +2074,7 @@ impl From<String> for QualifiedName {
Self {
items: vec![value],
// TODO: See comment in struct def.
seperator: String::from("::"),
separator: String::from("::"),
}
}
}
Expand Down Expand Up @@ -2135,7 +2135,7 @@ impl IndexMut<usize> for QualifiedName {

impl Display for QualifiedName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.items.join(&self.seperator))
write!(f, "{}", self.items.join(&self.separator))
}
}

Expand Down

0 comments on commit ab0607b

Please sign in to comment.