mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-08-01 16:37:56 -07:00
Address clippy warnings
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
use std::cell::UnsafeCell;
|
||||
use std::fs::File;
|
||||
use std::io::{IoSlice, Write};
|
||||
|
||||
use base::libc::{
|
||||
makedev, mknod, syscall, SYS_dup3, O_CLOEXEC, O_RDWR, O_WRONLY, STDERR_FILENO, STDIN_FILENO,
|
||||
STDOUT_FILENO, S_IFCHR,
|
||||
};
|
||||
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
|
||||
static mut KMSG: UnsafeCell<Option<File>> = UnsafeCell::new(None);
|
||||
static mut KMSG: RawFd = -1;
|
||||
|
||||
pub fn setup_klog() {
|
||||
unsafe {
|
||||
@@ -33,7 +33,7 @@ pub fn setup_klog() {
|
||||
fd = open_fd!(cstr!("/kmsg"), O_WRONLY | O_CLOEXEC);
|
||||
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
|
||||
@@ -46,10 +46,13 @@ pub fn setup_klog() {
|
||||
}
|
||||
|
||||
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 io2 = IoSlice::new(msg.as_bytes());
|
||||
let mut kmsg = unsafe { File::from_raw_fd(fd) };
|
||||
let _ = kmsg.write_vectored(&[io1, io2]).ok();
|
||||
mem::forget(kmsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user