diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-07 19:22:21 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 2f214f6c9935e8ce8df4732cde44a540a003258c (patch) | |
| tree | 6fe319433ef0d2ad75fcc58a50eaa632bb627ec9 /plugins/warp/src/matcher.rs | |
| parent | b4cf0be8816182c9efca037e27e9439482f8bf36 (diff) | |
[Rust] Reduce usage of `IntoCStr` in function signatures
This is being done to reduce complexity in function signatures, specifically many of the strings we are passing ultimately should be new types themselves instead of "just strings", things such as type ids.
Another place which was confusing was dealing with filesystem related APIs, this commit turns most of those params into a stricter `Path` type.
This is bringing the rust api more inline with both python and C++, where the wrapper eagerly converts the string into the languages standard string type.
Special consideration must be made for symbols or other possible non utf-8 objects.
This commit will be followed up with one that adds the `IntoCStr` bound on API's we want to keep as invalid utf-8 so we can for example, get section by name on a section with invalid utf-8.
Diffstat (limited to 'plugins/warp/src/matcher.rs')
| -rw-r--r-- | plugins/warp/src/matcher.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/plugins/warp/src/matcher.rs b/plugins/warp/src/matcher.rs index 6352cd7a..0ce258ad 100644 --- a/plugins/warp/src/matcher.rs +++ b/plugins/warp/src/matcher.rs @@ -159,7 +159,7 @@ impl Matcher { if let Some(ref_guid) = c.guid { // NOTE: We do not need to check for cyclic reference here because // NOTE: GUID references are unable to be referenced by themselves. - if view.type_by_id(ref_guid.to_string()).is_none() { + if view.type_by_id(&ref_guid.to_string()).is_none() { // Add the referrer to the view if it is in the Matcher types if let Some(ref_ty) = matcher.types.get(&ref_guid) { inner_add_type_to_view(matcher, view, arch, visited_refs, &ref_ty); @@ -186,7 +186,7 @@ impl Matcher { // All nested types _should_ be added now, we can add this type. // TODO: Do we want to make unnamed types visible? I think we should, but some people might be opposed. let ty_name = ty.name.to_owned().unwrap_or_else(|| ty_id_str.clone()); - view.define_auto_type_with_id(ty_name, ty_id_str, &to_bn_type(arch, ty)); + view.define_auto_type_with_id(ty_name, &ty_id_str, &to_bn_type(arch, ty)); } _ => {} } @@ -409,7 +409,7 @@ impl MatcherSettings { }); bn_settings.register_setting_json( Self::TRIVIAL_FUNCTION_LEN_SETTING, - trivial_function_len_props.to_string(), + &trivial_function_len_props.to_string(), ); let minimum_function_len_props = json!({ @@ -421,7 +421,7 @@ impl MatcherSettings { }); bn_settings.register_setting_json( Self::MINIMUM_FUNCTION_LEN_SETTING, - minimum_function_len_props.to_string(), + &minimum_function_len_props.to_string(), ); let maximum_function_len_props = json!({ @@ -433,7 +433,7 @@ impl MatcherSettings { }); bn_settings.register_setting_json( Self::MAXIMUM_FUNCTION_LEN_SETTING, - maximum_function_len_props.to_string(), + &maximum_function_len_props.to_string(), ); let minimum_matched_constraints_props = json!({ @@ -445,7 +445,7 @@ impl MatcherSettings { }); bn_settings.register_setting_json( Self::MINIMUM_MATCHED_CONSTRAINTS_SETTING, - minimum_matched_constraints_props.to_string(), + &minimum_matched_constraints_props.to_string(), ); let trivial_function_adjacent_allowed_props = json!({ @@ -457,7 +457,7 @@ impl MatcherSettings { }); bn_settings.register_setting_json( Self::TRIVIAL_FUNCTION_ADJACENT_ALLOWED_SETTING, - trivial_function_adjacent_allowed_props.to_string(), + &trivial_function_adjacent_allowed_props.to_string(), ); } |
