Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Sep 1, 2023
1 parent 670650f commit 094c8c7
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 96 deletions.
2 changes: 1 addition & 1 deletion src/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl fmt::Debug for CString {
impl fmt::Debug for CStr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "\"")?;
for byte in self.to_bytes().iter() {
for byte in self.to_bytes() {
f.write_char(*byte as char)?;
}
write!(f, "\"")
Expand Down
2 changes: 1 addition & 1 deletion src/calls/alarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
pub unsafe fn alarm(seconds: u32) -> u32 {
let seconds = seconds as usize;
// This function is always successful.
syscall1(SYS_ALARM, seconds).expect("alarm() failed") as u32
syscall1(SYS_ALARM, seconds).unwrap_or_default() as u32
}
2 changes: 1 addition & 1 deletion src/calls/getegid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#[must_use]
pub unsafe fn getegid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETEGID).expect("getegid() failed") as gid_t
syscall0(SYS_GETEGID).unwrap_or_default() as gid_t
}
2 changes: 1 addition & 1 deletion src/calls/geteuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#[must_use]
pub unsafe fn geteuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETEUID).expect("geteuid() failed") as uid_t
syscall0(SYS_GETEUID).unwrap_or_default() as uid_t
}
2 changes: 1 addition & 1 deletion src/calls/getgid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#[must_use]
pub unsafe fn getgid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETGID).expect("getgid() failed") as gid_t
syscall0(SYS_GETGID).unwrap_or_default() as gid_t
}
2 changes: 1 addition & 1 deletion src/calls/getpgrp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#[must_use]
pub unsafe fn getpgrp() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPGRP).expect("getpgrp() failed") as pid_t
syscall0(SYS_GETPGRP).unwrap_or_default() as pid_t
}
2 changes: 1 addition & 1 deletion src/calls/getpid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#[must_use]
pub unsafe fn getpid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPID).expect("getpid() failed") as pid_t
syscall0(SYS_GETPID).unwrap_or_default() as pid_t
}
2 changes: 1 addition & 1 deletion src/calls/getppid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#[must_use]
pub unsafe fn getppid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPPID).expect("getppid() failed") as pid_t
syscall0(SYS_GETPPID).unwrap_or_default() as pid_t
}
2 changes: 1 addition & 1 deletion src/calls/getsid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
pub unsafe fn getsid(pid: pid_t) -> pid_t {
let pid = pid as usize;
// This function is always successful.
syscall1(SYS_GETSID, pid).expect("getsid() failed") as pid_t
syscall1(SYS_GETSID, pid).unwrap_or_default() as pid_t
}
2 changes: 1 addition & 1 deletion src/calls/gettid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#[must_use]
pub unsafe fn gettid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETTID).expect("getpid() failed") as pid_t
syscall0(SYS_GETTID).unwrap_or_default() as pid_t
}
2 changes: 1 addition & 1 deletion src/calls/getuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#[must_use]
pub unsafe fn getuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETUID).expect("getuid() failed") as uid_t
syscall0(SYS_GETUID).unwrap_or_default() as uid_t
}
16 changes: 8 additions & 8 deletions src/platform/linux-aarch64/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ pub unsafe fn getdents64(fd: i32, dirp: usize, count: size_t) -> Result<ssize_t,
#[must_use]
pub unsafe fn getegid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETEGID).expect("getegid() failed") as gid_t
syscall0(SYS_GETEGID).unwrap_or_default() as gid_t
}

/// Get the effective user ID of the calling process.
Expand All @@ -1560,7 +1560,7 @@ pub unsafe fn getegid() -> gid_t {
#[must_use]
pub unsafe fn geteuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETEUID).expect("geteuid() failed") as uid_t
syscall0(SYS_GETEUID).unwrap_or_default() as uid_t
}

/// Get the real group ID of the calling process.
Expand All @@ -1574,7 +1574,7 @@ pub unsafe fn geteuid() -> uid_t {
#[must_use]
pub unsafe fn getgid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETGID).expect("getgid() failed") as gid_t
syscall0(SYS_GETGID).unwrap_or_default() as gid_t
}

/// Get list of supplementary group Ids.
Expand Down Expand Up @@ -1690,7 +1690,7 @@ pub unsafe fn getpgid(pid: pid_t) -> Result<pid_t, Errno> {
#[must_use]
pub unsafe fn getpid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPID).expect("getpid() failed") as pid_t
syscall0(SYS_GETPID).unwrap_or_default() as pid_t
}

/// Get the process ID of the parent of the calling process.
Expand All @@ -1704,7 +1704,7 @@ pub unsafe fn getpid() -> pid_t {
#[must_use]
pub unsafe fn getppid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPPID).expect("getppid() failed") as pid_t
syscall0(SYS_GETPPID).unwrap_or_default() as pid_t
}

/// Get program scheduling priority.
Expand Down Expand Up @@ -1834,7 +1834,7 @@ pub unsafe fn getrusage(who: i32, usage: &mut rusage_t) -> Result<(), Errno> {
pub unsafe fn getsid(pid: pid_t) -> pid_t {
let pid = pid as usize;
// This function is always successful.
syscall1(SYS_GETSID, pid).expect("getsid() failed") as pid_t
syscall1(SYS_GETSID, pid).unwrap_or_default() as pid_t
}

/// Get current address to which the socket `sockfd` is bound.
Expand Down Expand Up @@ -1884,7 +1884,7 @@ pub unsafe fn getsockopt(
#[must_use]
pub unsafe fn gettid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETTID).expect("getpid() failed") as pid_t
syscall0(SYS_GETTID).unwrap_or_default() as pid_t
}

/// Get time.
Expand Down Expand Up @@ -1915,7 +1915,7 @@ pub unsafe fn gettimeofday(timeval: &mut timeval_t, tz: &mut timezone_t) -> Resu
#[must_use]
pub unsafe fn getuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETUID).expect("getuid() failed") as uid_t
syscall0(SYS_GETUID).unwrap_or_default() as uid_t
}

/// Get extended attribute value.
Expand Down
18 changes: 9 additions & 9 deletions src/platform/linux-arm/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ pub unsafe fn getdents64(fd: i32, dirp: usize, count: size_t) -> Result<ssize_t,
#[must_use]
pub unsafe fn getegid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETEGID).expect("getegid() failed") as gid_t
syscall0(SYS_GETEGID).unwrap_or_default() as gid_t
}

/// Get the effective user ID of the calling process.
Expand All @@ -1954,7 +1954,7 @@ pub unsafe fn getegid() -> gid_t {
#[must_use]
pub unsafe fn geteuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETEUID).expect("geteuid() failed") as uid_t
syscall0(SYS_GETEUID).unwrap_or_default() as uid_t
}

/// Get the real group ID of the calling process.
Expand All @@ -1968,7 +1968,7 @@ pub unsafe fn geteuid() -> uid_t {
#[must_use]
pub unsafe fn getgid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETGID).expect("getgid() failed") as gid_t
syscall0(SYS_GETGID).unwrap_or_default() as gid_t
}

/// Get list of supplementary group Ids.
Expand Down Expand Up @@ -2084,7 +2084,7 @@ pub unsafe fn getpgid(pid: pid_t) -> Result<pid_t, Errno> {
#[must_use]
pub unsafe fn getpgrp() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPGRP).expect("getpgrp() failed") as pid_t
syscall0(SYS_GETPGRP).unwrap_or_default() as pid_t
}

/// Get the process ID (PID) of the calling process.
Expand All @@ -2098,7 +2098,7 @@ pub unsafe fn getpgrp() -> pid_t {
#[must_use]
pub unsafe fn getpid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPID).expect("getpid() failed") as pid_t
syscall0(SYS_GETPID).unwrap_or_default() as pid_t
}

/// Get the process ID of the parent of the calling process.
Expand All @@ -2112,7 +2112,7 @@ pub unsafe fn getpid() -> pid_t {
#[must_use]
pub unsafe fn getppid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPPID).expect("getppid() failed") as pid_t
syscall0(SYS_GETPPID).unwrap_or_default() as pid_t
}

/// Get program scheduling priority.
Expand Down Expand Up @@ -2225,7 +2225,7 @@ pub unsafe fn getrusage(who: i32, usage: &mut rusage_t) -> Result<(), Errno> {
pub unsafe fn getsid(pid: pid_t) -> pid_t {
let pid = pid as usize;
// This function is always successful.
syscall1(SYS_GETSID, pid).expect("getsid() failed") as pid_t
syscall1(SYS_GETSID, pid).unwrap_or_default() as pid_t
}

/// Get current address to which the socket `sockfd` is bound.
Expand Down Expand Up @@ -2275,7 +2275,7 @@ pub unsafe fn getsockopt(
#[must_use]
pub unsafe fn gettid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETTID).expect("getpid() failed") as pid_t
syscall0(SYS_GETTID).unwrap_or_default() as pid_t
}

/// Get time.
Expand Down Expand Up @@ -2306,7 +2306,7 @@ pub unsafe fn gettimeofday(timeval: &mut timeval_t, tz: &mut timezone_t) -> Resu
#[must_use]
pub unsafe fn getuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETUID).expect("getuid() failed") as uid_t
syscall0(SYS_GETUID).unwrap_or_default() as uid_t
}

/// Get extended attribute value.
Expand Down
16 changes: 8 additions & 8 deletions src/platform/linux-loongarch64/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ pub unsafe fn getdents64(fd: i32, dirp: usize, count: size_t) -> Result<ssize_t,
#[must_use]
pub unsafe fn getegid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETEGID).expect("getegid() failed") as gid_t
syscall0(SYS_GETEGID).unwrap_or_default() as gid_t
}

/// Get the effective user ID of the calling process.
Expand All @@ -1432,7 +1432,7 @@ pub unsafe fn getegid() -> gid_t {
#[must_use]
pub unsafe fn geteuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETEUID).expect("geteuid() failed") as uid_t
syscall0(SYS_GETEUID).unwrap_or_default() as uid_t
}

/// Get the real group ID of the calling process.
Expand All @@ -1446,7 +1446,7 @@ pub unsafe fn geteuid() -> uid_t {
#[must_use]
pub unsafe fn getgid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETGID).expect("getgid() failed") as gid_t
syscall0(SYS_GETGID).unwrap_or_default() as gid_t
}

/// Get list of supplementary group Ids.
Expand Down Expand Up @@ -1562,7 +1562,7 @@ pub unsafe fn getpgid(pid: pid_t) -> Result<pid_t, Errno> {
#[must_use]
pub unsafe fn getpid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPID).expect("getpid() failed") as pid_t
syscall0(SYS_GETPID).unwrap_or_default() as pid_t
}

/// Get the process ID of the parent of the calling process.
Expand All @@ -1576,7 +1576,7 @@ pub unsafe fn getpid() -> pid_t {
#[must_use]
pub unsafe fn getppid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPPID).expect("getppid() failed") as pid_t
syscall0(SYS_GETPPID).unwrap_or_default() as pid_t
}

/// Get program scheduling priority.
Expand Down Expand Up @@ -1706,7 +1706,7 @@ pub unsafe fn getrusage(who: i32, usage: &mut rusage_t) -> Result<(), Errno> {
pub unsafe fn getsid(pid: pid_t) -> pid_t {
let pid = pid as usize;
// This function is always successful.
syscall1(SYS_GETSID, pid).expect("getsid() failed") as pid_t
syscall1(SYS_GETSID, pid).unwrap_or_default() as pid_t
}

/// Get current address to which the socket `sockfd` is bound.
Expand Down Expand Up @@ -1756,7 +1756,7 @@ pub unsafe fn getsockopt(
#[must_use]
pub unsafe fn gettid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETTID).expect("getpid() failed") as pid_t
syscall0(SYS_GETTID).unwrap_or_default() as pid_t
}

/// Get time.
Expand Down Expand Up @@ -1787,7 +1787,7 @@ pub unsafe fn gettimeofday(timeval: &mut timeval_t, tz: &mut timezone_t) -> Resu
#[must_use]
pub unsafe fn getuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETUID).expect("getuid() failed") as uid_t
syscall0(SYS_GETUID).unwrap_or_default() as uid_t
}

/// Get extended attribute value.
Expand Down
20 changes: 10 additions & 10 deletions src/platform/linux-mips/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub unsafe fn adjtimex(buf: &mut timex_t) -> Result<i32, Errno> {
pub unsafe fn alarm(seconds: u32) -> u32 {
let seconds = seconds as usize;
// This function is always successful.
syscall1(SYS_ALARM, seconds).expect("alarm() failed") as u32
syscall1(SYS_ALARM, seconds).unwrap_or_default() as u32
}

/// Start, flush or tune buffer-dirty-flush daemon.
Expand Down Expand Up @@ -2003,7 +2003,7 @@ pub unsafe fn getdents64(fd: i32, dirp: usize, count: size_t) -> Result<ssize_t,
#[must_use]
pub unsafe fn getegid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETEGID).expect("getegid() failed") as gid_t
syscall0(SYS_GETEGID).unwrap_or_default() as gid_t
}

/// Get the effective user ID of the calling process.
Expand All @@ -2017,7 +2017,7 @@ pub unsafe fn getegid() -> gid_t {
#[must_use]
pub unsafe fn geteuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETEUID).expect("geteuid() failed") as uid_t
syscall0(SYS_GETEUID).unwrap_or_default() as uid_t
}

/// Get the real group ID of the calling process.
Expand All @@ -2031,7 +2031,7 @@ pub unsafe fn geteuid() -> uid_t {
#[must_use]
pub unsafe fn getgid() -> gid_t {
// This function is always successful.
syscall0(SYS_GETGID).expect("getgid() failed") as gid_t
syscall0(SYS_GETGID).unwrap_or_default() as gid_t
}

/// Get list of supplementary group Ids.
Expand Down Expand Up @@ -2147,7 +2147,7 @@ pub unsafe fn getpgid(pid: pid_t) -> Result<pid_t, Errno> {
#[must_use]
pub unsafe fn getpgrp() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPGRP).expect("getpgrp() failed") as pid_t
syscall0(SYS_GETPGRP).unwrap_or_default() as pid_t
}

/// Get the process ID (PID) of the calling process.
Expand All @@ -2161,7 +2161,7 @@ pub unsafe fn getpgrp() -> pid_t {
#[must_use]
pub unsafe fn getpid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPID).expect("getpid() failed") as pid_t
syscall0(SYS_GETPID).unwrap_or_default() as pid_t
}

/// Get the process ID of the parent of the calling process.
Expand All @@ -2175,7 +2175,7 @@ pub unsafe fn getpid() -> pid_t {
#[must_use]
pub unsafe fn getppid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETPPID).expect("getppid() failed") as pid_t
syscall0(SYS_GETPPID).unwrap_or_default() as pid_t
}

/// Get program scheduling priority.
Expand Down Expand Up @@ -2305,7 +2305,7 @@ pub unsafe fn getrusage(who: i32, usage: &mut rusage_t) -> Result<(), Errno> {
pub unsafe fn getsid(pid: pid_t) -> pid_t {
let pid = pid as usize;
// This function is always successful.
syscall1(SYS_GETSID, pid).expect("getsid() failed") as pid_t
syscall1(SYS_GETSID, pid).unwrap_or_default() as pid_t
}

/// Get current address to which the socket `sockfd` is bound.
Expand Down Expand Up @@ -2355,7 +2355,7 @@ pub unsafe fn getsockopt(
#[must_use]
pub unsafe fn gettid() -> pid_t {
// This function is always successful.
syscall0(SYS_GETTID).expect("getpid() failed") as pid_t
syscall0(SYS_GETTID).unwrap_or_default() as pid_t
}

/// Get time.
Expand Down Expand Up @@ -2386,7 +2386,7 @@ pub unsafe fn gettimeofday(timeval: &mut timeval_t, tz: &mut timezone_t) -> Resu
#[must_use]
pub unsafe fn getuid() -> uid_t {
// This function is always successful.
syscall0(SYS_GETUID).expect("getuid() failed") as uid_t
syscall0(SYS_GETUID).unwrap_or_default() as uid_t
}

/// Get extended attribute value.
Expand Down
Loading

0 comments on commit 094c8c7

Please sign in to comment.