mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
ls,wc: remove unnecessary unsafe blocks
This commit is contained in:
parent
11f2249f15
commit
33a34e4e54
3 changed files with 4 additions and 4 deletions
|
@ -3179,8 +3179,8 @@ fn display_len_or_rdev(metadata: &Metadata, config: &Config) -> SizeOrDeviceId {
|
|||
if ft.is_char_device() || ft.is_block_device() {
|
||||
// A type cast is needed here as the `dev_t` type varies across OSes.
|
||||
let dev = metadata.rdev() as dev_t;
|
||||
let major = unsafe { major(dev) };
|
||||
let minor = unsafe { minor(dev) };
|
||||
let major = major(dev);
|
||||
let minor = minor(dev);
|
||||
return SizeOrDeviceId::Device(major.to_string(), minor.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
|
|||
let null_rdev = stat::fstat(null_file.as_raw_fd())
|
||||
.map_err(|_| 0_usize)?
|
||||
.st_rdev as libc::dev_t;
|
||||
if unsafe { (libc::major(null_rdev), libc::minor(null_rdev)) } != (1, 3) {
|
||||
if (libc::major(null_rdev), libc::minor(null_rdev)) != (1, 3) {
|
||||
// This is not a proper /dev/null, writing to it is probably bad
|
||||
// Bit of an edge case, but it has been known to happen
|
||||
return Err(0);
|
||||
|
|
|
@ -4407,7 +4407,7 @@ fn test_device_number() {
|
|||
let blk_dev_path = blk_dev.path();
|
||||
let blk_dev_meta = metadata(blk_dev_path.as_path()).unwrap();
|
||||
let blk_dev_number = blk_dev_meta.rdev() as dev_t;
|
||||
let (major, minor) = unsafe { (major(blk_dev_number), minor(blk_dev_number)) };
|
||||
let (major, minor) = (major(blk_dev_number), minor(blk_dev_number));
|
||||
let major_minor_str = format!("{major}, {minor}");
|
||||
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue