add unused_must_use lint

This commit is contained in:
auronandace
2026-02-11 09:48:47 +00:00
parent 395c6ba33b
commit a3c67e898d
18 changed files with 43 additions and 43 deletions
+1 -1
View File
@@ -164,7 +164,7 @@ pub unsafe extern "C" fn globfree(pglob: *mut glob_t) {
}
if !path.is_null() {
unsafe {
CString::from_raw(path);
drop(CString::from_raw(path));
}
}
}
+2 -2
View File
@@ -132,8 +132,8 @@ impl Dns {
let flags = pop_n16!();
let queries_len = pop_n16!();
let answers_len = pop_n16!();
pop_n16!();
pop_n16!();
let _ = pop_n16!();
let _ = pop_n16!();
let mut queries = Vec::new();
for _query_i in 0..queries_len {
+2 -2
View File
@@ -37,7 +37,7 @@ pub static mut HOST_STAYOPEN: c_int = 0;
#[unsafe(no_mangle)]
pub unsafe extern "C" fn endhostent() {
if unsafe { HOSTDB } >= 0 {
Sys::close(unsafe { HOSTDB });
if let Ok(()) = Sys::close(unsafe { HOSTDB }) {}; // TODO handle error
}
unsafe { HOSTDB = -1 };
}
@@ -48,7 +48,7 @@ pub unsafe extern "C" fn sethostent(stayopen: c_int) {
if unsafe { HOSTDB } < 0 {
unsafe { HOSTDB = Sys::open(c"/etc/hosts".into(), O_RDONLY, 0).or_minus_one_errno() }
} else {
Sys::lseek(unsafe { HOSTDB }, 0, SEEK_SET);
if let Ok(_) = Sys::lseek(unsafe { HOSTDB }, 0, SEEK_SET) {}; // TODO handle error
}
unsafe { H_POS = 0 };
}
+7 -7
View File
@@ -39,10 +39,10 @@ pub fn lookup_host(host: &str) -> Result<LookupHost, c_int> {
if let Some(dns_addr) = parse_ipv4_string(&dns_string) {
let mut timespec = timespec::default();
Sys::clock_gettime(
if let Ok(()) = Sys::clock_gettime(
time::constants::CLOCK_REALTIME,
Out::from_mut(&mut timespec),
);
) {}; // TODO handle error
let tid = (timespec.tv_nsec >> 16) as u16;
let packet = Dns {
@@ -76,14 +76,14 @@ pub fn lookup_host(host: &str) -> Result<LookupHost, c_int> {
return Err(EIO);
}
if sys_socket::send(sock, packet_data_ptr, packet_data_len, 0) < 0 {
Box::from_raw(packet_data_ptr);
drop(Box::from_raw(packet_data_ptr));
return Err(EIO);
}
sock
};
unsafe {
Box::from_raw(packet_data_ptr);
drop(Box::from_raw(packet_data_ptr));
}
let i = 0 as socklen_t;
@@ -141,10 +141,10 @@ pub fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, c_int> {
);
let mut timespec = timespec::default();
Sys::clock_gettime(
if let Ok(()) = Sys::clock_gettime(
time::constants::CLOCK_REALTIME,
Out::from_mut(&mut timespec),
);
) {}; // TODO handle error
let tid = (timespec.tv_nsec >> 16) as u16;
let packet = Dns {
@@ -187,7 +187,7 @@ pub fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, c_int> {
}
unsafe {
Box::from_raw(packet_data_ptr);
drop(Box::from_raw(packet_data_ptr));
}
let i = mem::size_of::<sockaddr_in>() as socklen_t;
+8 -8
View File
@@ -181,21 +181,21 @@ fn bytes_to_box_str(bytes: &[u8]) -> Box<str> {
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/endnetent.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn endnetent() {
Sys::close(unsafe { NETDB });
if let Ok(()) = Sys::close(unsafe { NETDB }) {}; // TODO handle error
unsafe { NETDB = 0 };
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/endprotoent.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn endprotoent() {
Sys::close(unsafe { PROTODB });
if let Ok(()) = Sys::close(unsafe { PROTODB }) {}; // TODO handle error
unsafe { PROTODB = 0 };
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/endservent.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn endservent() {
Sys::close(unsafe { SERVDB });
if let Ok(()) = Sys::close(unsafe { SERVDB }) {}; // TODO handle error
unsafe { SERVDB = 0 };
}
@@ -783,7 +783,7 @@ pub unsafe extern "C" fn setnetent(stayopen: c_int) {
if unsafe { NETDB } == 0 {
unsafe { NETDB = Sys::open(c"/etc/networks".into(), O_RDONLY, 0).or_minus_one_errno() }
} else {
Sys::lseek(unsafe { NETDB }, 0, SEEK_SET);
if let Ok(_) = Sys::lseek(unsafe { NETDB }, 0, SEEK_SET) {}; // TODO handle errror
unsafe { N_POS = 0 };
}
}
@@ -795,7 +795,7 @@ pub unsafe extern "C" fn setprotoent(stayopen: c_int) {
if unsafe { PROTODB } == 0 {
unsafe { PROTODB = Sys::open(c"/etc/protocols".into(), O_RDONLY, 0).or_minus_one_errno() }
} else {
Sys::lseek(unsafe { PROTODB }, 0, SEEK_SET);
if let Ok(_) = Sys::lseek(unsafe { PROTODB }, 0, SEEK_SET) {}; // TODO handle error
unsafe { P_POS = 0 };
}
}
@@ -807,7 +807,7 @@ pub unsafe extern "C" fn setservent(stayopen: c_int) {
if unsafe { SERVDB } == 0 {
unsafe { SERVDB = Sys::open(c"/etc/services".into(), O_RDONLY, 0).or_minus_one_errno() }
} else {
Sys::lseek(unsafe { SERVDB }, 0, SEEK_SET);
if let Ok(_) = Sys::lseek(unsafe { SERVDB }, 0, SEEK_SET) {}; // TODO handle error
unsafe { S_POS = 0 };
}
}
@@ -1030,9 +1030,9 @@ pub unsafe extern "C" fn freeaddrinfo(res: *mut addrinfo) {
}
if !bai.ai_addr.is_null() {
if bai.ai_addrlen == mem::size_of::<sockaddr_in>() as socklen_t {
unsafe { Box::from_raw(bai.ai_addr as *mut sockaddr_in) };
unsafe { drop(Box::from_raw(bai.ai_addr as *mut sockaddr_in)) };
} else if bai.ai_addrlen == mem::size_of::<sockaddr_in6>() as socklen_t {
unsafe { Box::from_raw(bai.ai_addr as *mut sockaddr_in6) };
unsafe { drop(Box::from_raw(bai.ai_addr as *mut sockaddr_in6)) };
} else {
todo_skip!(0, "freeaddrinfo: unknown ai_addrlen {}", bai.ai_addrlen);
}
+1 -1
View File
@@ -38,7 +38,7 @@ pub(super) unsafe fn openpty(name: &mut [u8]) -> Result<(c_int, c_int), ()> {
}
let mut cursor = Cursor::new(name);
write!(cursor, "/dev/pts/{}\0", ptn);
if let Ok(()) = write!(cursor, "/dev/pts/{}\0", ptn) {}; // TODO handle error
let slave = unsafe {
fcntl::open(
+1 -1
View File
@@ -90,7 +90,7 @@ pub unsafe extern "C" fn regcomp(out: *mut regex_t, pat: *const c_char, cflags:
#[unsafe(no_mangle)]
#[linkage = "weak"] // redefined in GIT
pub unsafe extern "C" fn regfree(regex: *mut regex_t) {
unsafe { Box::from_raw((*regex).ptr) };
unsafe { drop(Box::from_raw((*regex).ptr)) };
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/regexec.html>.
+3 -3
View File
@@ -81,7 +81,7 @@ pub unsafe extern "C" fn sem_unlink(name: *const c_char) -> c_int {
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sem_trywait.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sem_wait(sem: *mut sem_t) -> c_int {
unsafe { get(sem) }.wait(None, CLOCK_MONOTONIC);
if let Ok(()) = unsafe { get(sem) }.wait(None, CLOCK_MONOTONIC) {}; // TODO handle error
0
}
@@ -93,7 +93,7 @@ pub unsafe extern "C" fn sem_clockwait(
clock_id: clockid_t,
abstime: *const timespec,
) -> c_int {
unsafe { get(sem) }.wait(Some(&unsafe { *abstime }), clock_id);
if let Ok(()) = unsafe { get(sem) }.wait(Some(&unsafe { *abstime }), clock_id) {}; // TODO handle error
0
}
@@ -101,7 +101,7 @@ pub unsafe extern "C" fn sem_clockwait(
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sem_timedwait.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sem_timedwait(sem: *mut sem_t, abstime: *const timespec) -> c_int {
unsafe { get(sem) }.wait(Some(&unsafe { *abstime }), CLOCK_REALTIME);
if let Ok(()) = unsafe { get(sem) }.wait(Some(&unsafe { *abstime }), CLOCK_REALTIME) {}; // TODO handle error
0
}
+3 -3
View File
@@ -580,7 +580,7 @@ pub unsafe extern "C" fn fopen(filename: *const c_char, mode: *const c_char) ->
.map(|f| Box::into_raw(f))
.map_err(|err| {
// TODO: guard type
Sys::close(fd);
if let Ok(()) = Sys::close(fd) {}; // TODO handle error
err
})
.or_errno_null_mut()
@@ -1320,11 +1320,11 @@ pub unsafe extern "C" fn tmpfile() -> *mut FILE {
let fp = unsafe { fdopen(fd, c"w+".as_ptr()) };
{
let file_name = unsafe { CStr::from_ptr(file_name) };
Sys::unlink(file_name);
if let Ok(()) = Sys::unlink(file_name) {}; // TODO handle error
}
if fp.is_null() {
Sys::close(fd);
if let Ok(()) = Sys::close(fd) {}; // TODO handle error
}
fp
+1 -1
View File
@@ -697,7 +697,7 @@ pub(crate) unsafe fn inner_printf<T: c_str::Kind>(
} else {
// TODO: wcsrtombs wrapper
for c in text.iter().filter_map(|u| char::from_u32((*u).into())) {
write!(w, "{}", c);
if let Ok(()) = write!(w, "{}", c) {}; // TODO handle error
}
}
continue;
+2 -2
View File
@@ -157,7 +157,7 @@ pub unsafe extern "C" fn lstat(path: *const c_char, buf: *mut stat) -> c_int {
// TODO: Rustify
let res = Sys::fstat(fd, buf).map(|()| 0).or_minus_one_errno();
Sys::close(fd);
if let Ok(()) = Sys::close(fd) {}; // TODO handle error
res
}
@@ -230,7 +230,7 @@ pub unsafe extern "C" fn stat(file: *const c_char, buf: *mut stat) -> c_int {
// TODO: Rustify
let res = Sys::fstat(fd, buf).map(|()| 0).or_minus_one_errno();
Sys::close(fd);
if let Ok(()) = Sys::close(fd) {}; // TODO handle error
res
}
+1 -1
View File
@@ -52,7 +52,7 @@ pub unsafe extern "C" fn statvfs(file: *const c_char, buf: *mut statvfs) -> c_in
let res = Sys::fstatvfs(fd, buf).map(|()| 0).or_minus_one_errno();
Sys::close(fd);
if let Ok(()) = Sys::close(fd) {}; // TODO handle error
res
}
+1 -1
View File
@@ -111,7 +111,7 @@ pub unsafe extern "C" fn openlog(ident: *const c_char, opt: c_int, facility: c_i
// Ensure log is ready to write now instead of checking on the first message.
if conf.contains(logger::Config::NoDelay) {
params.open_logger();
if let Ok(()) = params.open_logger() {}; // TODO handle error
}
}
+2 -2
View File
@@ -1060,7 +1060,7 @@ pub unsafe extern "C" fn symlink(path1: *const c_char, path2: *const c_char) ->
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sync.html>.
#[unsafe(no_mangle)]
pub extern "C" fn sync() {
Sys::sync();
if let Ok(()) = Sys::sync() {}; // TODO handle error
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/tcgetpgrp.html>.
@@ -1094,7 +1094,7 @@ pub unsafe extern "C" fn truncate(path: *const c_char, length: off_t) -> c_int {
let res = ftruncate(fd, length);
Sys::close(fd);
if let Ok(()) = Sys::close(fd) {}; // TODO handle error
res
}