Skip to content

Commit

Permalink
update_lint non_reentrant_functions
Browse files Browse the repository at this point in the history
Signed-off-by: mojave2 <[email protected]>
  • Loading branch information
kiscad committed Jun 26, 2023
1 parent c900d4a commit 9cd4b13
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions clippy_lints/src/non_reentrant_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,11 @@ impl EarlyLintPass for NonReentrantFunctions {
fn is_reentrant_fn(func: &Expr) -> bool {
match &func.kind {
ExprKind::Path(_, Path { segments, .. }) => {
if segments.len() != 2 || !format!("{:?}", segments[0].ident).starts_with("libc#") {
if segments.len() != 2 || segments[0].ident.name != rustc_span::sym::libc {
return false;
}
let ident = format!("{:?}", segments[1].ident);
check_reentrant_by_fn_name(&ident)
matches!(segments[1].ident.as_str(), "strtok" | "localtime")
},
_ => false,
}
}

fn check_reentrant_by_fn_name(func: &str) -> bool {
let name = func.split('#').next().unwrap();
name == "strtok" || name == "localtime"
}

0 comments on commit 9cd4b13

Please sign in to comment.