mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-07 19:01:39 -08:00
Fix compile errors and cleanup
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "../missing.hpp"
|
||||
#include "../xwrap.hpp"
|
||||
#include "../files.hpp"
|
||||
#include "../misc.hpp"
|
||||
#include "../logging.hpp"
|
||||
#include "../missing.hpp"
|
||||
#include "../base-rs.hpp"
|
||||
|
||||
@@ -179,10 +179,8 @@ struct byte_data : public byte_view {
|
||||
byte_data() = default;
|
||||
byte_data(void *buf, size_t sz) : byte_view(buf, sz) {}
|
||||
|
||||
// We don't want mutable references to be copied or moved around; pass bytes as byte_view
|
||||
// Subclasses are free to implement their own constructors
|
||||
byte_data(const byte_data &) = delete;
|
||||
byte_data(byte_data &&) = delete;
|
||||
// byte_data, or any of its subclass, can be copied as byte_data
|
||||
byte_data(const byte_data &o) : byte_data(o._buf, o._sz) {}
|
||||
|
||||
// Transparent conversion from common C++ types to mutable byte references
|
||||
byte_data(std::string &s, bool with_nul = true)
|
||||
@@ -194,9 +192,7 @@ struct byte_data : public byte_view {
|
||||
operator rust::Slice<uint8_t>() { return rust::Slice<uint8_t>(_buf, _sz); }
|
||||
|
||||
using byte_view::buf;
|
||||
using byte_view::sz;
|
||||
uint8_t *buf() { return _buf; }
|
||||
size_t &sz() { return _sz; }
|
||||
|
||||
void swap(byte_data &o);
|
||||
std::vector<size_t> patch(byte_view from, byte_view to);
|
||||
|
||||
@@ -10,7 +10,7 @@ static inline int fexecve(int fd, char* const* argv, char* const* envp) {
|
||||
syscall(__NR_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
|
||||
if (errno == ENOSYS) {
|
||||
char buf[256];
|
||||
std::snprintf(buf, sizeof(buf), "/proc/self/fd/%d", fd);
|
||||
ssprintf(buf, sizeof(buf), "/proc/self/fd/%d", fd);
|
||||
execve(buf, argv, envp);
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -132,7 +132,7 @@ void chunk_out_stream::finalize() {
|
||||
}
|
||||
|
||||
ssize_t byte_channel::read(void *buf, size_t len) {
|
||||
len = std::min((size_t) len, _data.sz() - _pos);
|
||||
len = std::min((size_t) len, _data._sz- _pos);
|
||||
memcpy(buf, _data.buf() + _pos, len);
|
||||
_pos += len;
|
||||
return len;
|
||||
@@ -142,7 +142,7 @@ bool byte_channel::write(const void *buf, size_t len) {
|
||||
resize(_pos + len);
|
||||
memcpy(_data.buf() + _pos, buf, len);
|
||||
_pos += len;
|
||||
_data.sz() = std::max(_data.sz(), _pos);
|
||||
_data._sz= std::max(_data.sz(), _pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ off_t byte_channel::seek(off_t off, int whence) {
|
||||
np = _pos + off;
|
||||
break;
|
||||
case SEEK_END:
|
||||
np = _data.sz() + off;
|
||||
np = _data._sz+ off;
|
||||
break;
|
||||
case SEEK_SET:
|
||||
np = off;
|
||||
|
||||
Reference in New Issue
Block a user