unsafe-checker

FFI Calling C functions

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "unsafe-checker" with this command: npx skills add rustfs/rustfs/rustfs-rustfs-unsafe-checker

Unsafe Rust Checker

When Unsafe is Valid

Use Case Example

FFI Calling C functions

Low-level abstractions Implementing Vec , Arc

Performance Measured bottleneck with safe alternative too slow

NOT valid: Escaping borrow checker without understanding why.

Required Documentation

// SAFETY: <why this is safe> unsafe { ... }

/// # Safety /// <caller requirements> pub unsafe fn dangerous() { ... }

Quick Reference

Operation Safety Requirements

*ptr deref Valid, aligned, initialized

&*ptr

  • No aliasing violations

transmute

Same size, valid bit pattern

extern "C"

Correct signature, ABI

static mut

Synchronization guaranteed

impl Send/Sync

Actually thread-safe

Common Errors

Error Fix

Null pointer deref Check for null before deref

Use after free Ensure lifetime validity

Data race Add proper synchronization

Alignment violation Use #[repr(C)] , check alignment

Invalid bit pattern Use MaybeUninit

Missing SAFETY comment Add // SAFETY:

Deprecated → Better

Deprecated Use Instead

mem::uninitialized()

MaybeUninit<T>

mem::zeroed() for refs MaybeUninit<T>

Raw pointer arithmetic NonNull<T> , ptr::add

CString::new().unwrap().as_ptr()

Store CString first

static mut

AtomicT or Mutex

Manual extern bindgen

FFI Crates

Direction Crate

C → Rust bindgen

Rust → C cbindgen

Python PyO3

Node.js napi-rs

Claude knows unsafe Rust. Focus on SAFETY comments and soundness.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

unsafe-checker

No summary provided by upstream source.

Repository SourceNeeds Review
General

unsafe-checker

No summary provided by upstream source.

Repository SourceNeeds Review
General

coding-guidelines

No summary provided by upstream source.

Repository SourceNeeds Review
General

m05-type-driven

No summary provided by upstream source.

Repository SourceNeeds Review