Skip to content

Commit 76b1b68

Browse files
committed
rm ptr::NonNull
1 parent 9f56bf5 commit 76b1b68

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

src/uu/chcon/src/fts.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ use std::ffi::{CStr, CString, OsStr};
88
use std::marker::PhantomData;
99
use std::os::raw::{c_int, c_long, c_short};
1010
use std::path::Path;
11-
use std::ptr::NonNull;
1211
use std::{io, iter, ptr, slice};
1312

1413
use crate::errors::{Error, Result};
1514
use crate::os_str_to_c_string;
1615

1716
#[derive(Debug)]
1817
pub(crate) struct FTS {
19-
fts: NonNull<fts_sys::FTS>,
18+
fts: ptr::NonNull<fts_sys::FTS>,
2019

21-
entry: Option<NonNull<fts_sys::FTSENT>>,
20+
entry: Option<ptr::NonNull<fts_sys::FTSENT>>,
2221
_phantom_data: PhantomData<fts_sys::FTSENT>,
2322
}
2423

@@ -52,7 +51,7 @@ impl FTS {
5251
// - `compar` is None.
5352
let fts = unsafe { fts_sys::fts_open(path_argv.as_ptr().cast(), options, None) };
5453

55-
let fts = NonNull::new(fts)
54+
let fts = ptr::NonNull::new(fts)
5655
.ok_or_else(|| Error::from_io("fts_open()", io::Error::last_os_error()))?;
5756

5857
Ok(Self {
@@ -71,7 +70,7 @@ impl FTS {
7170
// pointer assumed to be valid.
7271
let new_entry = unsafe { fts_sys::fts_read(self.fts.as_ptr()) };
7372

74-
self.entry = NonNull::new(new_entry);
73+
self.entry = ptr::NonNull::new(new_entry);
7574
if self.entry.is_none() {
7675
let r = io::Error::last_os_error();
7776
if let Some(0) = r.raw_os_error() {
@@ -110,14 +109,14 @@ impl Drop for FTS {
110109

111110
#[derive(Debug)]
112111
pub(crate) struct EntryRef<'fts> {
113-
pub(crate) pointer: NonNull<fts_sys::FTSENT>,
112+
pub(crate) pointer: ptr::NonNull<fts_sys::FTSENT>,
114113

115114
_fts: PhantomData<&'fts FTS>,
116115
_phantom_data: PhantomData<fts_sys::FTSENT>,
117116
}
118117

119118
impl<'fts> EntryRef<'fts> {
120-
fn new(_fts: &'fts FTS, entry: NonNull<fts_sys::FTSENT>) -> Self {
119+
fn new(_fts: &'fts FTS, entry: ptr::NonNull<fts_sys::FTSENT>) -> Self {
121120
Self {
122121
pointer: entry,
123122
_fts: PhantomData,
@@ -161,7 +160,7 @@ impl<'fts> EntryRef<'fts> {
161160
return None;
162161
}
163162

164-
NonNull::new(entry.fts_path)
163+
ptr::NonNull::new(entry.fts_path)
165164
.map(|path_ptr| {
166165
let path_size = usize::from(entry.fts_pathlen).saturating_add(1);
167166

@@ -174,7 +173,7 @@ impl<'fts> EntryRef<'fts> {
174173
}
175174

176175
pub(crate) fn access_path(&self) -> Option<&Path> {
177-
NonNull::new(self.as_ref().fts_accpath)
176+
ptr::NonNull::new(self.as_ref().fts_accpath)
178177
.map(|path_ptr| {
179178
// SAFETY: `entry.fts_accpath` is a non-null pointer that is assumed to be valid.
180179
unsafe { CStr::from_ptr(path_ptr.as_ptr()) }
@@ -184,7 +183,7 @@ impl<'fts> EntryRef<'fts> {
184183
}
185184

186185
pub(crate) fn stat(&self) -> Option<&libc::stat> {
187-
NonNull::new(self.as_ref().fts_statp).map(|stat_ptr| {
186+
ptr::NonNull::new(self.as_ref().fts_statp).map(|stat_ptr| {
188187
// SAFETY: `entry.fts_statp` is a non-null pointer that is assumed to be valid.
189188
unsafe { stat_ptr.as_ref() }
190189
})

src/uu/du/src/du.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ fn get_size_on_disk(path: &Path) -> u64 {
227227

228228
// bind file so it stays in scope until end of function
229229
// if it goes out of scope the handle below becomes invalid
230-
let file = match fs::File::open(path) {
230+
let file = match File::open(path) {
231231
Ok(file) => file,
232232
Err(_) => return size_on_disk, // opening directories will fail
233233
};
@@ -240,7 +240,7 @@ fn get_size_on_disk(path: &Path) -> u64 {
240240
file.as_raw_handle() as HANDLE,
241241
FileStandardInfo,
242242
file_info_ptr as _,
243-
std::mem::size_of::<FILE_STANDARD_INFO>() as u32,
243+
size_of::<FILE_STANDARD_INFO>() as u32,
244244
);
245245

246246
if success != 0 {
@@ -255,7 +255,7 @@ fn get_size_on_disk(path: &Path) -> u64 {
255255
fn get_file_info(path: &Path) -> Option<FileInfo> {
256256
let mut result = None;
257257

258-
let file = match fs::File::open(path) {
258+
let file = match File::open(path) {
259259
Ok(file) => file,
260260
Err(_) => return result,
261261
};
@@ -268,7 +268,7 @@ fn get_file_info(path: &Path) -> Option<FileInfo> {
268268
file.as_raw_handle() as HANDLE,
269269
FileIdInfo,
270270
file_info_ptr as _,
271-
std::mem::size_of::<FILE_ID_INFO>() as u32,
271+
size_of::<FILE_ID_INFO>() as u32,
272272
);
273273

274274
if success != 0 {

src/uu/numfmt/src/numfmt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn parse_options(args: &ArgMatches) -> Result<NumfmtOptions> {
234234

235235
let invalid = InvalidModes::from_str(args.get_one::<String>(INVALID).unwrap()).unwrap();
236236

237-
let zero_terminated = args.get_flag(options::ZERO_TERMINATED);
237+
let zero_terminated = args.get_flag(ZERO_TERMINATED);
238238

239239
Ok(NumfmtOptions {
240240
transform,
@@ -387,8 +387,8 @@ pub fn uu_app() -> Command {
387387
.value_name("INVALID"),
388388
)
389389
.arg(
390-
Arg::new(options::ZERO_TERMINATED)
391-
.long(options::ZERO_TERMINATED)
390+
Arg::new(ZERO_TERMINATED)
391+
.long(ZERO_TERMINATED)
392392
.short('z')
393393
.help("line delimiter is NUL, not newline")
394394
.action(ArgAction::SetTrue),

src/uu/split/src/platform/windows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn instantiate_current_writer(
2222
.write(true)
2323
.create(true)
2424
.truncate(true)
25-
.open(std::path::Path::new(&filename))
25+
.open(Path::new(&filename))
2626
.map_err(|_| {
2727
Error::new(
2828
ErrorKind::Other,
@@ -33,7 +33,7 @@ pub fn instantiate_current_writer(
3333
// re-open file that we previously created to append to it
3434
std::fs::OpenOptions::new()
3535
.append(true)
36-
.open(std::path::Path::new(&filename))
36+
.open(Path::new(&filename))
3737
.map_err(|_| {
3838
Error::new(
3939
ErrorKind::Other,

0 commit comments

Comments
 (0)