mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-13 03:34:29 +00:00
Address clippy warnings
This commit is contained in:
parent
9e26b73813
commit
2654382c43
@ -405,8 +405,8 @@ macro_rules! const_assert_eq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assert ABI layout
|
// Assert ABI layout
|
||||||
const_assert_eq!(mem::size_of::<&Utf8CStr>(), mem::size_of::<[usize; 2]>());
|
const_assert_eq!(size_of::<&Utf8CStr>(), size_of::<[usize; 2]>());
|
||||||
const_assert_eq!(mem::align_of::<&Utf8CStr>(), mem::align_of::<[usize; 2]>());
|
const_assert_eq!(align_of::<&Utf8CStr>(), align_of::<[usize; 2]>());
|
||||||
|
|
||||||
// File system path extensions types
|
// File system path extensions types
|
||||||
|
|
||||||
@ -471,7 +471,7 @@ impl<'a> FsPathBuf<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Deref for FsPathBuf<'a> {
|
impl Deref for FsPathBuf<'_> {
|
||||||
type Target = FsPath;
|
type Target = FsPath;
|
||||||
|
|
||||||
fn deref(&self) -> &FsPath {
|
fn deref(&self) -> &FsPath {
|
||||||
@ -479,7 +479,7 @@ impl<'a> Deref for FsPathBuf<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DerefMut for FsPathBuf<'a> {
|
impl DerefMut for FsPathBuf<'_> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
FsPath::from_mut(&mut self.0)
|
FsPath::from_mut(&mut self.0)
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ impl Directory {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let entry = &*e;
|
let entry = &*e;
|
||||||
let d_name = CStr::from_ptr(entry.d_name.as_ptr());
|
let d_name = CStr::from_ptr(entry.d_name.as_ptr());
|
||||||
return if d_name == cstr!(".") || d_name == cstr!("..") {
|
if d_name == cstr!(".") || d_name == cstr!("..") {
|
||||||
self.read()
|
self.read()
|
||||||
} else {
|
} else {
|
||||||
let e = DirEntry {
|
let e = DirEntry {
|
||||||
@ -342,7 +342,7 @@ impl Directory {
|
|||||||
d_name_len: d_name.to_bytes_with_nul().len(),
|
d_name_len: d_name.to_bytes_with_nul().len(),
|
||||||
};
|
};
|
||||||
Ok(Some(e))
|
Ok(Some(e))
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
use std::cell::UnsafeCell;
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io::{IoSlice, Write};
|
|
||||||
|
|
||||||
use base::libc::{
|
use base::libc::{
|
||||||
makedev, mknod, syscall, SYS_dup3, O_CLOEXEC, O_RDWR, O_WRONLY, STDERR_FILENO, STDIN_FILENO,
|
makedev, mknod, syscall, SYS_dup3, O_CLOEXEC, O_RDWR, O_WRONLY, STDERR_FILENO, STDIN_FILENO,
|
||||||
STDOUT_FILENO, S_IFCHR,
|
STDOUT_FILENO, S_IFCHR,
|
||||||
};
|
};
|
||||||
use base::{cstr, exit_on_error, open_fd, raw_cstr, FsPath, LogLevel, Logger, Utf8CStr, LOGGER};
|
use base::{cstr, exit_on_error, open_fd, raw_cstr, FsPath, LogLevel, Logger, Utf8CStr, LOGGER};
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{IoSlice, Write};
|
||||||
|
use std::mem;
|
||||||
|
use std::os::fd::{FromRawFd, IntoRawFd, RawFd};
|
||||||
|
|
||||||
// SAFETY: magiskinit is single threaded
|
// SAFETY: magiskinit is single threaded
|
||||||
static mut KMSG: UnsafeCell<Option<File>> = UnsafeCell::new(None);
|
static mut KMSG: RawFd = -1;
|
||||||
|
|
||||||
pub fn setup_klog() {
|
pub fn setup_klog() {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -33,7 +33,7 @@ pub fn setup_klog() {
|
|||||||
fd = open_fd!(cstr!("/kmsg"), O_WRONLY | O_CLOEXEC);
|
fd = open_fd!(cstr!("/kmsg"), O_WRONLY | O_CLOEXEC);
|
||||||
FsPath::from(cstr!("/kmsg")).remove().ok();
|
FsPath::from(cstr!("/kmsg")).remove().ok();
|
||||||
}
|
}
|
||||||
*KMSG.get() = fd.map(|fd| fd.into()).ok();
|
KMSG = fd.map(|fd| fd.into_raw_fd()).unwrap_or(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable kmsg rate limiting
|
// Disable kmsg rate limiting
|
||||||
@ -46,10 +46,13 @@ pub fn setup_klog() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn kmsg_log_write(_: LogLevel, msg: &Utf8CStr) {
|
fn kmsg_log_write(_: LogLevel, msg: &Utf8CStr) {
|
||||||
if let Some(kmsg) = unsafe { &mut *KMSG.get() } {
|
let fd = unsafe { KMSG };
|
||||||
|
if fd >= 0 {
|
||||||
let io1 = IoSlice::new("magiskinit: ".as_bytes());
|
let io1 = IoSlice::new("magiskinit: ".as_bytes());
|
||||||
let io2 = IoSlice::new(msg.as_bytes());
|
let io2 = IoSlice::new(msg.as_bytes());
|
||||||
|
let mut kmsg = unsafe { File::from_raw_fd(fd) };
|
||||||
let _ = kmsg.write_vectored(&[io1, io2]).ok();
|
let _ = kmsg.write_vectored(&[io1, io2]).ok();
|
||||||
|
mem::forget(kmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user