1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:27:46 +00:00

Everywhere: Run clang-format

This commit is contained in:
Idan Horowitz 2022-04-01 20:58:27 +03:00 committed by Linus Groh
parent 0376c127f6
commit 086969277e
1665 changed files with 8479 additions and 8479 deletions

View file

@ -125,8 +125,8 @@ public:
private:
const String m_executable_path;
const Vector<StringView> m_arguments;
const Vector<String> m_environment;
Vector<StringView> const m_arguments;
Vector<String> const m_environment;
SoftMMU m_mmu;
NonnullOwnPtr<SoftCPU> m_cpu;

View file

@ -371,11 +371,11 @@ int Emulator::virt$symlink(FlatPtr params_addr)
mmu().copy_from_vm(&params, params_addr, sizeof(params));
auto target = mmu().copy_buffer_from_vm((FlatPtr)params.target.characters, params.target.length);
params.target.characters = (const char*)target.data();
params.target.characters = (char const*)target.data();
params.target.length = target.size();
auto link = mmu().copy_buffer_from_vm((FlatPtr)params.linkpath.characters, params.linkpath.length);
params.linkpath.characters = (const char*)link.data();
params.linkpath.characters = (char const*)link.data();
params.linkpath.length = link.size();
return syscall(SC_symlink, &params);
@ -387,11 +387,11 @@ int Emulator::virt$rename(FlatPtr params_addr)
mmu().copy_from_vm(&params, params_addr, sizeof(params));
auto new_path = mmu().copy_buffer_from_vm((FlatPtr)params.new_path.characters, params.new_path.length);
params.new_path.characters = (const char*)new_path.data();
params.new_path.characters = (char const*)new_path.data();
params.new_path.length = new_path.size();
auto old_path = mmu().copy_buffer_from_vm((FlatPtr)params.old_path.characters, params.old_path.length);
params.old_path.characters = (const char*)old_path.data();
params.old_path.characters = (char const*)old_path.data();
params.old_path.length = old_path.size();
return syscall(SC_rename, &params);
@ -403,11 +403,11 @@ int Emulator::virt$set_coredump_metadata(FlatPtr params_addr)
mmu().copy_from_vm(&params, params_addr, sizeof(params));
auto key = mmu().copy_buffer_from_vm((FlatPtr)params.key.characters, params.key.length);
params.key.characters = (const char*)key.data();
params.key.characters = (char const*)key.data();
params.key.length = key.size();
auto value = mmu().copy_buffer_from_vm((FlatPtr)params.value.characters, params.value.length);
params.value.characters = (const char*)value.data();
params.value.characters = (char const*)value.data();
params.value.length = value.size();
return syscall(SC_set_coredump_metadata, &params);
@ -416,7 +416,7 @@ int Emulator::virt$set_coredump_metadata(FlatPtr params_addr)
int Emulator::virt$dbgputstr(FlatPtr characters, int length)
{
auto buffer = mmu().copy_buffer_from_vm(characters, length);
dbgputstr((const char*)buffer.data(), buffer.size());
dbgputstr((char const*)buffer.data(), buffer.size());
return 0;
}
@ -437,7 +437,7 @@ int Emulator::virt$chown(FlatPtr params_addr)
mmu().copy_from_vm(&params, params_addr, sizeof(params));
auto path = mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length);
params.path.characters = (const char*)path.data();
params.path.characters = (char const*)path.data();
params.path.length = path.size();
return syscall(SC_chown, &params);
@ -635,7 +635,7 @@ int Emulator::virt$recvmsg(int sockfd, FlatPtr msg_addr, int flags)
mmu().copy_from_vm(mmu_iovs.data(), (FlatPtr)mmu_msg.msg_iov, mmu_msg.msg_iovlen * sizeof(iovec));
Vector<ByteBuffer, 1> buffers;
Vector<iovec, 1> iovs;
for (const auto& iov : mmu_iovs) {
for (auto const& iov : mmu_iovs) {
auto buffer_result = ByteBuffer::create_uninitialized(iov.iov_len);
if (buffer_result.is_error())
return -ENOMEM;
@ -819,7 +819,7 @@ u32 Emulator::virt$open(u32 params_addr)
host_params.dirfd = params.dirfd;
host_params.mode = params.mode;
host_params.options = params.options;
host_params.path.characters = (const char*)path.data();
host_params.path.characters = (char const*)path.data();
host_params.path.length = path.size();
return syscall(SC_open, &host_params);
@ -1315,7 +1315,7 @@ int Emulator::virt$realpath(FlatPtr params_addr)
auto& host_buffer = buffer_result.value();
Syscall::SC_realpath_params host_params;
host_params.path = { (const char*)path.data(), path.size() };
host_params.path = { (char const*)path.data(), path.size() };
host_params.buffer = { (char*)host_buffer.data(), host_buffer.size() };
int rc = syscall(SC_realpath, &host_params);
if (rc < 0)
@ -1587,7 +1587,7 @@ int Emulator::virt$readlink(FlatPtr params_addr)
auto& host_buffer = buffer_result.value();
Syscall::SC_readlink_params host_params;
host_params.path = { (const char*)path.data(), path.size() };
host_params.path = { (char const*)path.data(), path.size() };
host_params.buffer = { (char*)host_buffer.data(), host_buffer.size() };
int rc = syscall(SC_readlink, &host_params);
if (rc < 0)

View file

@ -208,7 +208,7 @@ Mallocation* MallocTracer::find_mallocation_after(FlatPtr address)
return found_mallocation;
}
void MallocTracer::audit_read(const Region& region, FlatPtr address, size_t size)
void MallocTracer::audit_read(Region const& region, FlatPtr address, size_t size)
{
if (!m_auditing_enabled)
return;
@ -259,7 +259,7 @@ void MallocTracer::audit_read(const Region& region, FlatPtr address, size_t size
}
}
void MallocTracer::audit_write(const Region& region, FlatPtr address, size_t size)
void MallocTracer::audit_write(Region const& region, FlatPtr address, size_t size)
{
if (!m_auditing_enabled)
return;

View file

@ -63,8 +63,8 @@ public:
void target_did_realloc(Badge<Emulator>, FlatPtr address, size_t);
void target_did_change_chunk_size(Badge<Emulator>, FlatPtr, size_t);
void audit_read(const Region&, FlatPtr address, size_t);
void audit_write(const Region&, FlatPtr address, size_t);
void audit_read(Region const&, FlatPtr address, size_t);
void audit_write(Region const&, FlatPtr address, size_t);
void dump_leak_report();
@ -72,7 +72,7 @@ private:
template<typename Callback>
void for_each_mallocation(Callback callback) const;
Mallocation* find_mallocation(const Region&, FlatPtr);
Mallocation* find_mallocation(Region const&, FlatPtr);
Mallocation* find_mallocation(FlatPtr);
Mallocation* find_mallocation_before(FlatPtr);
Mallocation* find_mallocation_after(FlatPtr);
@ -89,11 +89,11 @@ private:
bool m_auditing_enabled { true };
};
ALWAYS_INLINE Mallocation* MallocTracer::find_mallocation(const Region& region, FlatPtr address)
ALWAYS_INLINE Mallocation* MallocTracer::find_mallocation(Region const& region, FlatPtr address)
{
if (!is<MmapRegion>(region))
return nullptr;
if (!static_cast<const MmapRegion&>(region).is_malloc_block())
if (!static_cast<MmapRegion const&>(region).is_malloc_block())
return nullptr;
auto* malloc_data = static_cast<MmapRegion&>(const_cast<Region&>(region)).malloc_metadata();
if (!malloc_data)

View file

@ -12,7 +12,7 @@
namespace UserspaceEmulator {
static void* mmap_initialized(size_t bytes, char initial_value, const char* name)
static void* mmap_initialized(size_t bytes, char initial_value, char const* name)
{
auto* ptr = mmap_with_name(nullptr, bytes, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, name);
VERIFY(ptr != MAP_FAILED);

View file

@ -51,7 +51,7 @@ public:
MallocRegionMetadata* malloc_metadata() { return m_malloc_metadata; }
void set_malloc_metadata(Badge<MallocTracer>, NonnullOwnPtr<MallocRegionMetadata> metadata) { m_malloc_metadata = move(metadata); }
const String& name() const { return m_name; }
String const& name() const { return m_name; }
String lib_name() const
{
if (m_name.contains("Loader.so"sv))

View file

@ -9,7 +9,7 @@
namespace UserspaceEmulator {
Vector<Range, 2> Range::carve(const Range& taken) const
Vector<Range, 2> Range::carve(Range const& taken) const
{
VERIFY((taken.size() % PAGE_SIZE) == 0);
Vector<Range, 2> parts;

View file

@ -30,7 +30,7 @@ public:
VirtualAddress end() const { return m_base.offset(m_size); }
bool operator==(const Range& other) const
bool operator==(Range const& other) const
{
return m_base == other.m_base && m_size == other.m_size;
}
@ -42,12 +42,12 @@ public:
return base >= m_base && base.offset(size) <= end();
}
bool contains(const Range& other) const
bool contains(Range const& other) const
{
return contains(other.base(), other.size());
}
Vector<Range, 2> carve(const Range&) const;
Vector<Range, 2> carve(Range const&) const;
Range split_at(VirtualAddress address)
{

View file

@ -33,7 +33,7 @@ void RangeAllocator::dump() const
}
}
void RangeAllocator::carve_at_index(int index, const Range& range)
void RangeAllocator::carve_at_index(int index, Range const& range)
{
auto remaining_parts = m_available_ranges[index].carve(range);
VERIFY(remaining_parts.size() >= 1);
@ -142,7 +142,7 @@ Optional<Range> RangeAllocator::allocate_specific(VirtualAddress base, size_t si
return {};
}
void RangeAllocator::deallocate(const Range& range)
void RangeAllocator::deallocate(Range const& range)
{
VERIFY(m_total_range.contains(range));
VERIFY(range.size());

View file

@ -20,16 +20,16 @@ public:
Optional<Range> allocate_anywhere(size_t, size_t alignment = PAGE_SIZE);
Optional<Range> allocate_specific(VirtualAddress, size_t);
Optional<Range> allocate_randomized(size_t, size_t alignment);
void deallocate(const Range&);
void deallocate(Range const&);
void reserve_user_range(VirtualAddress, size_t);
void dump() const;
bool contains(const Range& range) const { return m_total_range.contains(range); }
bool contains(Range const& range) const { return m_total_range.contains(range); }
private:
void carve_at_index(int, const Range&);
void carve_at_index(int, Range const&);
Vector<Range> m_available_ranges;
Range m_total_range;

View file

@ -21,7 +21,7 @@ class Region {
public:
virtual ~Region() = default;
const Range& range() const { return m_range; }
Range const& range() const { return m_range; }
u32 base() const { return m_range.base().get(); }
u32 size() const { return m_range.size(); }
@ -63,7 +63,7 @@ public:
virtual u8* shadow_data() = 0;
Emulator& emulator() { return m_emulator; }
const Emulator& emulator() const { return m_emulator; }
Emulator const& emulator() const { return m_emulator; }
template<typename T>
bool fast_is() const = delete;

View file

@ -46,7 +46,7 @@
namespace UserspaceEmulator {
template<typename T>
ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* message)
ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message)
{
if (value_with_shadow.is_uninitialized()) [[unlikely]] {
reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message);
@ -54,7 +54,7 @@ ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* messag
}
}
ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(const char* message) const
ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(char const* message) const
{
if (m_flags_tainted) [[unlikely]] {
reportln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n", getpid(), message);
@ -208,7 +208,7 @@ void SoftCPU::push_string(StringView string)
m_emulator.mmu().write8({ 0x23, esp().value() + string.length() }, shadow_wrap_as_initialized((u8)'\0'));
}
void SoftCPU::push_buffer(const u8* data, size_t size)
void SoftCPU::push_buffer(u8 const* data, size_t size)
{
set_esp({ esp().value() - size, esp().shadow() });
warn_if_uninitialized(esp(), "push_buffer");

View file

@ -81,7 +81,7 @@ public:
ValueWithShadow<u16> pop16();
void push_string(StringView);
void push_buffer(const u8* data, size_t);
void push_buffer(u8 const* data, size_t);
u16 segment(X86::SegmentRegister seg) const { return m_segment[(int)seg]; }
u16& segment(X86::SegmentRegister seg) { return m_segment[(int)seg]; }
@ -463,7 +463,7 @@ public:
m_flags_tainted = a.is_uninitialized() || b.is_uninitialized() || c.is_uninitialized();
}
void warn_if_flags_tainted(const char* message) const;
void warn_if_flags_tainted(char const* message) const;
// ^X86::InstructionStream
virtual bool can_read() override { return false; }

View file

@ -28,7 +28,7 @@
} while (0)
template<typename T>
ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* message)
ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message)
{
if (value_with_shadow.is_uninitialized()) [[unlikely]] {
reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message);

View file

@ -305,11 +305,11 @@ void SoftMMU::write256(X86::LogicalAddress address, ValueWithShadow<u256> value)
region->write256(address.offset() - region->base(), value);
}
void SoftMMU::copy_to_vm(FlatPtr destination, const void* source, size_t size)
void SoftMMU::copy_to_vm(FlatPtr destination, void const* source, size_t size)
{
// FIXME: We should have a way to preserve the shadow data here as well.
for (size_t i = 0; i < size; ++i)
write8({ 0x23, destination + i }, shadow_wrap_as_initialized(((const u8*)source)[i]));
write8({ 0x23, destination + i }, shadow_wrap_as_initialized(((u8 const*)source)[i]));
}
void SoftMMU::copy_from_vm(void* destination, const FlatPtr source, size_t size)
@ -336,7 +336,7 @@ bool SoftMMU::fast_fill_memory8(X86::LogicalAddress address, size_t size, ValueW
if (!region->contains(address.offset() + size - 1))
return false;
if (is<MmapRegion>(*region) && static_cast<const MmapRegion&>(*region).is_malloc_block()) {
if (is<MmapRegion>(*region) && static_cast<MmapRegion const&>(*region).is_malloc_block()) {
if (auto* tracer = m_emulator.malloc_tracer()) {
// FIXME: Add a way to audit an entire range of memory instead of looping here!
for (size_t i = 0; i < size; ++i) {
@ -361,7 +361,7 @@ bool SoftMMU::fast_fill_memory32(X86::LogicalAddress address, size_t count, Valu
if (!region->contains(address.offset() + (count * sizeof(u32)) - 1))
return false;
if (is<MmapRegion>(*region) && static_cast<const MmapRegion&>(*region).is_malloc_block()) {
if (is<MmapRegion>(*region) && static_cast<MmapRegion const&>(*region).is_malloc_block()) {
if (auto* tracer = m_emulator.malloc_tracer()) {
// FIXME: Add a way to audit an entire range of memory instead of looping here!
for (size_t i = 0; i < count; ++i) {

View file

@ -88,7 +88,7 @@ public:
bool fast_fill_memory8(X86::LogicalAddress, size_t size, ValueWithShadow<u8>);
bool fast_fill_memory32(X86::LogicalAddress, size_t size, ValueWithShadow<u32>);
void copy_to_vm(FlatPtr destination, const void* source, size_t);
void copy_to_vm(FlatPtr destination, void const* source, size_t);
void copy_from_vm(void* destination, const FlatPtr source, size_t);
ByteBuffer copy_buffer_from_vm(const FlatPtr source, size_t);

View file

@ -116,7 +116,7 @@ public:
return false;
}
ValueAndShadowReference<T>& operator=(const ValueWithShadow<T>&);
ValueAndShadowReference<T>& operator=(ValueWithShadow<T> const&);
T shadow_as_value() const requires(IsTriviallyConstructible<T>)
{
@ -165,14 +165,14 @@ ALWAYS_INLINE ValueWithShadow<T> shadow_wrap_with_taint_from(T value, U const& t
}
template<typename T>
inline ValueWithShadow<T>::ValueWithShadow(const ValueAndShadowReference<T>& other)
inline ValueWithShadow<T>::ValueWithShadow(ValueAndShadowReference<T> const& other)
: m_value(other.value())
, m_shadow(other.shadow())
{
}
template<typename T>
inline ValueAndShadowReference<T>& ValueAndShadowReference<T>::operator=(const ValueWithShadow<T>& other)
inline ValueAndShadowReference<T>& ValueAndShadowReference<T>::operator=(ValueWithShadow<T> const& other)
{
m_value = other.value();
m_shadow = other.shadow();