Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/devno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ impl BlkidDevno {

/// Create a `BlkidDevno` from major and minor numbers.
pub fn from_device_numbers(major: maj_t, minor: min_t) -> Self {
#[allow(unused_unsafe)] // No longer unsafe in libc 0.2.133
#[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.133")]
BlkidDevno(unsafe { libc::makedev(major, minor) })
}

/// Get the major number.
pub fn major(&self) -> maj_t {
#[allow(unused_unsafe)]
#[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.171")]

@coderabbitai coderabbitai Bot Dec 11, 2025 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

libc crate changelog major minor functions safe version history

💡 Result:

Summary — what libc is and its version history

  • libc is the Rust crate providing raw, platform-specific FFI bindings (types, constants, extern "C" function signatures). It is intentionally a thin, unsafe binding layer — callers are responsible for safe usage. [1][2]
  • The crate moved from 0.1 → 0.2 (RFC 1291) with API/typedef changes (e.g., top-level exports, size_t/ssize_t defined as usize/isize on main platforms). The project maintains a long 0.2.x series while preparing a planned 1.0 (roadmap on the repo). [3][4]
  • Current published releases (many 0.2.x releases; recently active: 0.2.17x…/0.2.174 etc. and 1.0.0-alpha releases on the registry). See the releases list for precise version history. [2]

About “major / minor / functions / safe”

  • Semantic versioning: libc has stayed at 0.2.* for a long time (breaking changes were made when moving from 0.1 → 0.2). A future 1.0 is planned and may introduce breaking changes; maintainers have discussed migration strategy. [3][4]
  • Function safety: libc exposes raw C APIs (extern "C" fn signatures) and thus their use is generally unsafe in Rust — the crate itself does not generally provide safe wrappers. In other words, calling most libc functions requires unsafe or a safe wrapper in a higher-level crate. The README and design rationale describe libc as raw FFI bindings. [1][2]
  • Changes making things “safe”: there is no broad history of libc converting C functions into safe Rust APIs inside the crate — safe, ergonomic wrappers are normally provided by other crates (or by application code). libc’s scope is to match platform APIs faithfully rather than to wrap them in safe abstractions. [1][3]

Where to get the authoritative changelog / releases

  • GitHub repo (source, CHANGELOG, issues, roadmap, v1.0 branch): rust-lang/libc. Use the Releases/tags and commits for specific change details. [1]
  • Crate/release listing (crates.io / lib.rs) shows published versions and dates (0.2.x history and recent alpha 1.0 pre-releases). Check the crate page for exact release timestamps. [2]

If you want, I can:

  • fetch the precise 5 most important changelog entries (with dates) from the GitHub Releases/CHANGELOG, or
  • list which 0.2.x releases contain specific changes (e.g., 0.2.169 matching rustc c_char changes). Which would you prefer?

🏁 Script executed:

#!/bin/bash
# Check the crate registry info for libc version history
curl -s "https://crates.io/api/v1/crates/libc" | jq '.versions[] | select(.num | test("0.2.17[01]")) | {num: .num, created_at: .created_at}' | head -20

Repository: stratis-storage/libblkid-rs

Length of output: 210


🏁 Script executed:

#!/bin/bash
# Try to fetch libc changelog from crates.io or check the GitHub release info
curl -s "https://api.github.com/repos/rust-lang/libc/releases" | jq '.[] | select(.tag_name | test("0.2.171")) | {tag_name: .tag_name, body: .body}' | head -50

Repository: stratis-storage/libblkid-rs

Length of output: 3976


Remove or correct the reason attribute — major/minor are still unsafe.

In libc 0.2.171, major, minor, and makedev became const fn (#4208), not safe functions. The #[allow(unused_unsafe)] reason is inaccurate: these functions remain unsafe to call. Either remove the reason or update it to reflect why the unsafe block is genuinely needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor
🧩 Analysis chain

Remove or correct the reason attribute — major/minor are still unsafe.

In libc 0.2.171, major, minor, and makedev became const fn (#4208), not safe functions. The #[allow(unused_unsafe)] reason is inaccurate: these functions remain unsafe to call. Either remove the reason or update it to reflect why the unsafe block is genuinely needed.

Developers disagree w/ you and agree w/ me: bdrung/3cpio@52827a6 .

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch the commit that the user referenced
curl -s "https://api.github.com/repos/bdrung/3cpio/commits/52827a6e8136453a19805dd6e1e27fd932d24bfd" | jq -r '.commit.message, .files[].patch' | head -100

Length of output: 987


🏁 Script executed:

#!/bin/bash
# Check libc changelog for makedev/major/minor becoming safe
curl -s "https://raw.githubusercontent.com/rust-lang/libc/main/CHANGELOG.md" | grep -A 5 -B 5 -i "makedev\|major\|minor" | grep -A 5 -B 5 "0.2.1[37]"

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Check the libc PR that made these const fn to see if they also became safe
curl -s "https://api.github.com/repos/rust-lang/libc/pulls/4208" | jq -r '.title, .body'

Length of output: 1443


@mulkieran, you're absolutely right, and I apologize for the incorrect analysis.

The evidence from the commit you linked and the libc PR #4208 clearly shows that makedev, major, and minor were changed to safe const fn in those versions, not just const fn. As the PR description states: "makedev, major and minor are macros on most Unixes, there is no need for them to be unsafe."

Your reason attributes are accurate:

  • These functions are no longer unsafe to call
  • The #[allow(unused_unsafe)] is the correct way to handle the now-unnecessary unsafe blocks
  • The version information in your reasons is correct

Thank you for the correction and the reference!

🐰💭
/_/
( o.o )

^ <
(thinking...)


🧬 Code Graph Analysis Results

[src/devno.rs] lines (approximate extraction)

  1. from_device_numbers
    """
    pub fn from_device_numbers(major: maj_t, minor: min_t) -> Self {
    #[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.133")]
    BlkidDevno(unsafe { libc::makedev(major, minor) })
    }
    """
  • Description: Creates a BlkidDevno from major and minor numbers using libc::makedev. Note the allow attribute with a specific libc version reason.
  1. major()
    """
    pub fn major(&self) -> maj_t {
    #[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.171")]
    unsafe {
    libc::major(self.0)
    }
    }
    """
  • Description: Retrieves the major number from the device number. Uses unsafe block with a libc version-based reason.
  1. minor()
    """
    pub fn minor(&self) -> min_t {
    #[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.171")]
    unsafe {
    libc::minor(self.0)
    }
    }
    """
  • Description: Retrieves the minor number from the device number. Uses unsafe block with a libc version-based reason.

unsafe {
libc::major(self.0)
}
}

/// Get the minor number.
pub fn minor(&self) -> min_t {
#[allow(unused_unsafe)]
#[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.171")]
unsafe {
libc::minor(self.0)
}
Expand Down