Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Qinheping Hu <qinhh@amazon.com>
  • Loading branch information
celinval and qinheping authored Jul 31, 2024
1 parent e2a3a31 commit 9baaf0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions scripts/std-analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ summary=$results/summary.csv

# write header
echo -n "crate," > $summary
tr -d [:digit:], < $results/alloc_scan_overall.csv \
tr -d "[:digit:],;" < $results/alloc_scan_overall.csv \
| tr -s '\n' ',' >> $summary
echo "" >> $summary

Expand All @@ -104,7 +104,7 @@ for f in $results/*overall.csv; do
fname=$(basename $f)
crate=${fname%_scan_overall.csv}
echo -n "$crate," >> $summary
tr -d [:alpha:]_, < $f | tr -s '\n' ',' \
tr -d [:alpha:]_,; < $f | tr -s '\n' ',' \
>> $summary
echo "" >> $summary
done
Expand Down
10 changes: 5 additions & 5 deletions tools/scanner/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use serde::{ser::SerializeStruct, Serialize, Serializer};
use stable_mir::mir::mono::Instance;
use stable_mir::mir::visit::{Location, PlaceContext, PlaceRef};
use stable_mir::mir::{
Body, Constant, MirVisitor, Mutability, ProjectionElem, Safety, Terminator, TerminatorKind,
Body, MirVisitor, Mutability, ProjectionElem, Safety, Terminator, TerminatorKind,
};
use stable_mir::ty::{AdtDef, AdtKind, FnDef, GenericArgs, RigidTy, Ty, TyKind};
use stable_mir::ty::{AdtDef, AdtKind, FnDef, GenericArgs, MirConst, RigidTy, Ty, TyKind};
use stable_mir::visitor::{Visitable, Visitor};
use stable_mir::{CrateDef, CrateItem};
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -94,7 +94,7 @@ impl OverallStats {
return None;
};
let fn_sig = kind.fn_sig().unwrap();
let is_unsafe = fn_sig.skip_binder().unsafety == Safety::Unsafe;
let is_unsafe = fn_sig.skip_binder().safety == Safety::Unsafe;
self.fn_stats.get_mut(&item).unwrap().is_unsafe = Some(is_unsafe);
Some((item, is_unsafe))
})
Expand Down Expand Up @@ -139,7 +139,7 @@ impl OverallStats {
};
let unsafe_ops = FnUnsafeOperations::new(item.name()).collect(&item.body());
let fn_sig = kind.fn_sig().unwrap();
let is_unsafe = fn_sig.skip_binder().unsafety == Safety::Unsafe;
let is_unsafe = fn_sig.skip_binder().safety == Safety::Unsafe;
self.fn_stats.get_mut(&item).unwrap().has_unsafe_ops =
Some(unsafe_ops.has_unsafe());
Some((is_unsafe, unsafe_ops))
Expand Down Expand Up @@ -387,7 +387,7 @@ impl<'a> MirVisitor for BodyVisitor<'a> {
match &term.kind {
TerminatorKind::Call { func, .. } => {
let fn_sig = func.ty(self.body.locals()).unwrap().kind().fn_sig().unwrap();
if fn_sig.value.unsafety == Safety::Unsafe {
if fn_sig.value.safety == Safety::Unsafe {
self.props.unsafe_call += 1;
}
}
Expand Down

0 comments on commit 9baaf0d

Please sign in to comment.