You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Cleanup some code
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
using namespace std;
|
||||
|
||||
int fd_pathat(int dirfd, const char *name, char *path, size_t size) {
|
||||
if (fd_path(dirfd, byte_slice(path, size)) < 0)
|
||||
if (fd_path(dirfd, u8_mut_slice(path, size)) < 0)
|
||||
return -1;
|
||||
auto len = strlen(path);
|
||||
path[len] = '/';
|
||||
|
||||
@@ -15,7 +15,7 @@ static int fmt_and_log_with_rs(LogLevel level, const char *fmt, va_list ap) {
|
||||
buf[0] = '\0';
|
||||
// Fortify logs when a fatal error occurs. Do not run through fortify again
|
||||
int len = std::min(__call_bypassing_fortify(vsnprintf)(buf, sz, fmt, ap), sz - 1);
|
||||
log_with_rs(level, rust::Slice(reinterpret_cast<const uint8_t *>(buf), len));
|
||||
log_with_rs(level, u8_slice(buf, sz));
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,10 +120,15 @@ struct StringCmp {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
rust::Slice<uint8_t> byte_slice(T *buf, size_t sz) {
|
||||
rust::Slice<uint8_t> u8_mut_slice(T *buf, size_t sz) {
|
||||
return rust::Slice(reinterpret_cast<uint8_t *>(buf), sz);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
rust::Slice<const uint8_t> u8_slice(T *buf, size_t sz) {
|
||||
return rust::Slice(reinterpret_cast<const uint8_t *>(buf), sz);
|
||||
}
|
||||
|
||||
uint64_t parse_uint64_hex(std::string_view s);
|
||||
int parse_int(std::string_view s);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user