mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
AK: Simplify constructors and conversions from nullptr_t
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
This commit is contained in:
parent
9dc44bf8c4
commit
e6f907a155
Notes:
sideshowbarker
2024-07-18 23:54:24 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/e6f907a1556 Pull-request: https://github.com/SerenityOS/serenity/pull/4908 Reviewed-by: https://github.com/asynts Reviewed-by: https://github.com/emanuele6
@ -31,7 +31,7 @@ namespace AK {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class Badge {
|
class Badge {
|
||||||
friend T;
|
friend T;
|
||||||
Badge() { }
|
constexpr Badge() = default;
|
||||||
|
|
||||||
Badge(const Badge&) = delete;
|
Badge(const Badge&) = delete;
|
||||||
Badge& operator=(const Badge&) = delete;
|
Badge& operator=(const Badge&) = delete;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <AK/NonnullRefPtr.h>
|
||||||
|
#include <AK/OwnPtr.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <AK/Span.h>
|
#include <AK/Span.h>
|
||||||
@ -42,6 +43,7 @@ public:
|
|||||||
static NonnullRefPtr<ByteBufferImpl> create_zeroed(size_t);
|
static NonnullRefPtr<ByteBufferImpl> create_zeroed(size_t);
|
||||||
static NonnullRefPtr<ByteBufferImpl> copy(const void*, size_t);
|
static NonnullRefPtr<ByteBufferImpl> copy(const void*, size_t);
|
||||||
|
|
||||||
|
ByteBufferImpl() = delete;
|
||||||
~ByteBufferImpl() { clear(); }
|
~ByteBufferImpl() { clear(); }
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
@ -92,7 +94,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
explicit ByteBufferImpl(size_t);
|
explicit ByteBufferImpl(size_t);
|
||||||
ByteBufferImpl(const void*, size_t);
|
ByteBufferImpl(const void*, size_t);
|
||||||
ByteBufferImpl() { }
|
|
||||||
|
|
||||||
u8* m_data { nullptr };
|
u8* m_data { nullptr };
|
||||||
size_t m_size { 0 };
|
size_t m_size { 0 };
|
||||||
@ -100,8 +101,7 @@ private:
|
|||||||
|
|
||||||
class ByteBuffer {
|
class ByteBuffer {
|
||||||
public:
|
public:
|
||||||
ByteBuffer() { }
|
ByteBuffer() = default;
|
||||||
ByteBuffer(std::nullptr_t) { }
|
|
||||||
ByteBuffer(const ByteBuffer& other)
|
ByteBuffer(const ByteBuffer& other)
|
||||||
: m_impl(other.m_impl)
|
: m_impl(other.m_impl)
|
||||||
{
|
{
|
||||||
@ -159,11 +159,35 @@ public:
|
|||||||
u8* data() { return m_impl ? m_impl->data() : nullptr; }
|
u8* data() { return m_impl ? m_impl->data() : nullptr; }
|
||||||
const u8* data() const { return m_impl ? m_impl->data() : nullptr; }
|
const u8* data() const { return m_impl ? m_impl->data() : nullptr; }
|
||||||
|
|
||||||
Bytes bytes() { return m_impl ? m_impl->bytes() : nullptr; }
|
Bytes bytes()
|
||||||
ReadonlyBytes bytes() const { return m_impl ? m_impl->bytes() : nullptr; }
|
{
|
||||||
|
if (m_impl) {
|
||||||
|
return m_impl->bytes();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
ReadonlyBytes bytes() const
|
||||||
|
{
|
||||||
|
if (m_impl) {
|
||||||
|
return m_impl->bytes();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
Span<u8> span() { return m_impl ? m_impl->span() : nullptr; }
|
Span<u8> span()
|
||||||
Span<const u8> span() const { return m_impl ? m_impl->span() : nullptr; }
|
{
|
||||||
|
if (m_impl) {
|
||||||
|
return m_impl->span();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
Span<const u8> span() const
|
||||||
|
{
|
||||||
|
if (m_impl) {
|
||||||
|
return m_impl->span();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
u8* offset_pointer(int offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
|
u8* offset_pointer(int offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
|
||||||
const u8* offset_pointer(int offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
|
const u8* offset_pointer(int offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
|
||||||
|
@ -74,7 +74,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DoublyLinkedList() { }
|
DoublyLinkedList() = default;
|
||||||
~DoublyLinkedList() { clear(); }
|
~DoublyLinkedList() { clear(); }
|
||||||
|
|
||||||
bool is_empty() const { return !m_head; }
|
bool is_empty() const { return !m_head; }
|
||||||
|
@ -110,7 +110,7 @@ public:
|
|||||||
friend InputStream& operator>><T>(InputStream&, LittleEndian<T>&);
|
friend InputStream& operator>><T>(InputStream&, LittleEndian<T>&);
|
||||||
friend OutputStream& operator<<<T>(OutputStream&, LittleEndian<T>);
|
friend OutputStream& operator<<<T>(OutputStream&, LittleEndian<T>);
|
||||||
|
|
||||||
constexpr LittleEndian() { }
|
constexpr LittleEndian() = default;
|
||||||
|
|
||||||
constexpr LittleEndian(T value)
|
constexpr LittleEndian(T value)
|
||||||
: m_value(convert_between_host_and_little_endian(value))
|
: m_value(convert_between_host_and_little_endian(value))
|
||||||
|
@ -32,7 +32,7 @@ namespace AK {
|
|||||||
|
|
||||||
class FlyString {
|
class FlyString {
|
||||||
public:
|
public:
|
||||||
FlyString() { }
|
FlyString() = default;
|
||||||
FlyString(const FlyString& other)
|
FlyString(const FlyString& other)
|
||||||
: m_impl(other.impl())
|
: m_impl(other.impl())
|
||||||
{
|
{
|
||||||
|
@ -266,7 +266,7 @@ struct StandardFormatter {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Formatter<T, typename EnableIf<IsIntegral<T>::value>::Type> : StandardFormatter {
|
struct Formatter<T, typename EnableIf<IsIntegral<T>::value>::Type> : StandardFormatter {
|
||||||
Formatter() { }
|
Formatter() = default;
|
||||||
explicit Formatter(StandardFormatter formatter)
|
explicit Formatter(StandardFormatter formatter)
|
||||||
: StandardFormatter(formatter)
|
: StandardFormatter(formatter)
|
||||||
{
|
{
|
||||||
@ -277,7 +277,7 @@ struct Formatter<T, typename EnableIf<IsIntegral<T>::value>::Type> : StandardFor
|
|||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct Formatter<StringView> : StandardFormatter {
|
struct Formatter<StringView> : StandardFormatter {
|
||||||
Formatter() { }
|
Formatter() = default;
|
||||||
explicit Formatter(StandardFormatter formatter)
|
explicit Formatter(StandardFormatter formatter)
|
||||||
: StandardFormatter(formatter)
|
: StandardFormatter(formatter)
|
||||||
{
|
{
|
||||||
@ -338,7 +338,7 @@ struct Formatter<float> : StandardFormatter {
|
|||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
struct Formatter<double> : StandardFormatter {
|
struct Formatter<double> : StandardFormatter {
|
||||||
Formatter() { }
|
Formatter() = default;
|
||||||
explicit Formatter(StandardFormatter formatter)
|
explicit Formatter(StandardFormatter formatter)
|
||||||
: StandardFormatter(formatter)
|
: StandardFormatter(formatter)
|
||||||
{
|
{
|
||||||
|
@ -25,9 +25,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Assertions.h"
|
#include <AK/Assertions.h>
|
||||||
#include "OwnPtr.h"
|
#include <AK/OwnPtr.h>
|
||||||
#include "StdLibExtras.h"
|
#include <AK/StdLibExtras.h>
|
||||||
|
#include <AK/Traits.h>
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
@ -38,7 +39,6 @@ template<typename Out, typename... In>
|
|||||||
class Function<Out(In...)> {
|
class Function<Out(In...)> {
|
||||||
public:
|
public:
|
||||||
Function() = default;
|
Function() = default;
|
||||||
Function(std::nullptr_t) { }
|
|
||||||
|
|
||||||
template<typename CallableType, class = typename EnableIf<!(IsPointer<CallableType>::value && IsFunction<typename RemovePointer<CallableType>::Type>::value) && IsRvalueReference<CallableType&&>::value>::Type>
|
template<typename CallableType, class = typename EnableIf<!(IsPointer<CallableType>::value && IsFunction<typename RemovePointer<CallableType>::Type>::value) && IsRvalueReference<CallableType&&>::value>::Type>
|
||||||
Function(CallableType&& callable)
|
Function(CallableType&& callable)
|
||||||
@ -83,7 +83,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
class CallableWrapperBase {
|
class CallableWrapperBase {
|
||||||
public:
|
public:
|
||||||
virtual ~CallableWrapperBase() { }
|
virtual ~CallableWrapperBase() = default;
|
||||||
virtual Out call(In...) const = 0;
|
virtual Out call(In...) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -98,7 +98,18 @@ private:
|
|||||||
CallableWrapper(const CallableWrapper&) = delete;
|
CallableWrapper(const CallableWrapper&) = delete;
|
||||||
CallableWrapper& operator=(const CallableWrapper&) = delete;
|
CallableWrapper& operator=(const CallableWrapper&) = delete;
|
||||||
|
|
||||||
Out call(In... in) const final override { return m_callable(forward<In>(in)...); }
|
Out call(In... in) const final override
|
||||||
|
{
|
||||||
|
if constexpr (requires { m_callable(forward<In>(in)...); }) {
|
||||||
|
return m_callable(forward<In>(in)...);
|
||||||
|
} else if constexpr (requires { m_callable(); }) {
|
||||||
|
return m_callable();
|
||||||
|
} else if constexpr (IsSame<void, Out>::value) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CallableType m_callable;
|
CallableType m_callable;
|
||||||
|
@ -54,7 +54,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HashMap() { }
|
HashMap() = default;
|
||||||
|
|
||||||
#ifndef SERENITY_LIBC_BUILD
|
#ifndef SERENITY_LIBC_BUILD
|
||||||
HashMap(std::initializer_list<Entry> list)
|
HashMap(std::initializer_list<Entry> list)
|
||||||
|
@ -87,7 +87,7 @@ class HashTable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HashTable() { }
|
HashTable() = default;
|
||||||
HashTable(size_t capacity) { rehash(capacity); }
|
HashTable(size_t capacity) { rehash(capacity); }
|
||||||
|
|
||||||
~HashTable()
|
~HashTable()
|
||||||
|
@ -34,8 +34,8 @@ namespace AK {
|
|||||||
class IDAllocator {
|
class IDAllocator {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IDAllocator() { }
|
IDAllocator() = default;
|
||||||
~IDAllocator() { }
|
~IDAllocator() = default;
|
||||||
|
|
||||||
int allocate()
|
int allocate()
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ inline T* InlineLinkedListNode<T>::next() const
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class InlineLinkedList {
|
class InlineLinkedList {
|
||||||
public:
|
public:
|
||||||
InlineLinkedList() { }
|
InlineLinkedList() = default;
|
||||||
|
|
||||||
bool is_empty() const { return !m_head; }
|
bool is_empty() const { return !m_head; }
|
||||||
size_t size_slow() const;
|
size_t size_slow() const;
|
||||||
|
@ -34,8 +34,8 @@ namespace AK {
|
|||||||
|
|
||||||
class JsonArray {
|
class JsonArray {
|
||||||
public:
|
public:
|
||||||
JsonArray() { }
|
JsonArray() = default;
|
||||||
~JsonArray() { }
|
~JsonArray() = default;
|
||||||
|
|
||||||
JsonArray(const JsonArray& other)
|
JsonArray(const JsonArray& other)
|
||||||
: m_values(other.m_values)
|
: m_values(other.m_values)
|
||||||
|
@ -37,8 +37,8 @@ namespace AK {
|
|||||||
|
|
||||||
class JsonObject {
|
class JsonObject {
|
||||||
public:
|
public:
|
||||||
JsonObject() { }
|
JsonObject() = default;
|
||||||
~JsonObject() { }
|
~JsonObject() = default;
|
||||||
|
|
||||||
JsonObject(const JsonObject& other)
|
JsonObject(const JsonObject& other)
|
||||||
: m_order(other.m_order)
|
: m_order(other.m_order)
|
||||||
|
@ -33,7 +33,7 @@ namespace AK {
|
|||||||
|
|
||||||
class LexicalPath {
|
class LexicalPath {
|
||||||
public:
|
public:
|
||||||
LexicalPath() { }
|
LexicalPath() = default;
|
||||||
explicit LexicalPath(const StringView&);
|
explicit LexicalPath(const StringView&);
|
||||||
|
|
||||||
bool is_valid() const { return m_is_valid; }
|
bool is_valid() const { return m_is_valid; }
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~LogStream() { }
|
virtual ~LogStream() = default;
|
||||||
|
|
||||||
virtual void write(const char*, int) const = 0;
|
virtual void write(const char*, int) const = 0;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ protected:
|
|||||||
bool empty() const { return m_size == 0; }
|
bool empty() const { return m_size == 0; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BufferedLogStream() { }
|
BufferedLogStream() = default;
|
||||||
|
|
||||||
virtual ~BufferedLogStream() override
|
virtual ~BufferedLogStream() override
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ public:
|
|||||||
|
|
||||||
class DebugLogStream final : public BufferedLogStream {
|
class DebugLogStream final : public BufferedLogStream {
|
||||||
public:
|
public:
|
||||||
DebugLogStream() { }
|
DebugLogStream() = default;
|
||||||
virtual ~DebugLogStream() override;
|
virtual ~DebugLogStream() override;
|
||||||
|
|
||||||
// DebugLogStream only checks `enabled` and possibly generates output while the destructor runs.
|
// DebugLogStream only checks `enabled` and possibly generates output while the destructor runs.
|
||||||
@ -128,7 +128,7 @@ private:
|
|||||||
#ifdef KERNEL
|
#ifdef KERNEL
|
||||||
class KernelLogStream final : public BufferedLogStream {
|
class KernelLogStream final : public BufferedLogStream {
|
||||||
public:
|
public:
|
||||||
KernelLogStream() { }
|
KernelLogStream() = default;
|
||||||
virtual ~KernelLogStream() override;
|
virtual ~KernelLogStream() override;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,7 @@ namespace AK {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class alignas(T) [[nodiscard]] Optional {
|
class alignas(T) [[nodiscard]] Optional {
|
||||||
public:
|
public:
|
||||||
Optional() { }
|
Optional() = default;
|
||||||
|
|
||||||
Optional(const T& value)
|
Optional(const T& value)
|
||||||
: m_has_value(true)
|
: m_has_value(true)
|
||||||
|
@ -34,7 +34,7 @@ namespace AK {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class OwnPtr {
|
class OwnPtr {
|
||||||
public:
|
public:
|
||||||
OwnPtr() { }
|
OwnPtr() = default;
|
||||||
explicit OwnPtr(T* ptr)
|
explicit OwnPtr(T* ptr)
|
||||||
: m_ptr(ptr)
|
: m_ptr(ptr)
|
||||||
{
|
{
|
||||||
@ -57,7 +57,6 @@ public:
|
|||||||
: m_ptr(other.leak_ptr())
|
: m_ptr(other.leak_ptr())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
OwnPtr(std::nullptr_t) {};
|
|
||||||
~OwnPtr()
|
~OwnPtr()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
@ -35,8 +35,8 @@ namespace AK {
|
|||||||
template<typename T, int segment_size = 1000>
|
template<typename T, int segment_size = 1000>
|
||||||
class Queue {
|
class Queue {
|
||||||
public:
|
public:
|
||||||
Queue() { }
|
Queue() = default;
|
||||||
~Queue() { }
|
~Queue() = default;
|
||||||
|
|
||||||
size_t size() const { return m_size; }
|
size_t size() const { return m_size; }
|
||||||
bool is_empty() const { return m_size == 0; }
|
bool is_empty() const { return m_size == 0; }
|
||||||
|
@ -92,7 +92,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RefCountedBase() { }
|
RefCountedBase() = default;
|
||||||
ALWAYS_INLINE ~RefCountedBase()
|
ALWAYS_INLINE ~RefCountedBase()
|
||||||
{
|
{
|
||||||
ASSERT(m_ref_count.load(AK::MemoryOrder::memory_order_relaxed) == 0);
|
ASSERT(m_ref_count.load(AK::MemoryOrder::memory_order_relaxed) == 0);
|
||||||
|
@ -143,7 +143,7 @@ public:
|
|||||||
Adopt
|
Adopt
|
||||||
};
|
};
|
||||||
|
|
||||||
RefPtr() { }
|
RefPtr() = default;
|
||||||
RefPtr(const T* ptr)
|
RefPtr(const T* ptr)
|
||||||
: m_bits(PtrTraits::as_bits(const_cast<T*>(ptr)))
|
: m_bits(PtrTraits::as_bits(const_cast<T*>(ptr)))
|
||||||
{
|
{
|
||||||
@ -205,7 +205,6 @@ public:
|
|||||||
m_bits.store(0xe0e0e0e0, AK::MemoryOrder::memory_order_relaxed);
|
m_bits.store(0xe0e0e0e0, AK::MemoryOrder::memory_order_relaxed);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
RefPtr(std::nullptr_t) { }
|
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
RefPtr(const OwnPtr<U>&) = delete;
|
RefPtr(const OwnPtr<U>&) = delete;
|
||||||
|
@ -37,7 +37,7 @@ namespace AK {
|
|||||||
template<typename ListType, typename ElementType>
|
template<typename ListType, typename ElementType>
|
||||||
class SinglyLinkedListIterator {
|
class SinglyLinkedListIterator {
|
||||||
public:
|
public:
|
||||||
SinglyLinkedListIterator() { }
|
SinglyLinkedListIterator() = default;
|
||||||
bool operator!=(const SinglyLinkedListIterator& other) const { return m_node != other.m_node; }
|
bool operator!=(const SinglyLinkedListIterator& other) const { return m_node != other.m_node; }
|
||||||
SinglyLinkedListIterator& operator++()
|
SinglyLinkedListIterator& operator++()
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SinglyLinkedList() { }
|
SinglyLinkedList() = default;
|
||||||
~SinglyLinkedList() { clear(); }
|
~SinglyLinkedList() { clear(); }
|
||||||
|
|
||||||
bool is_empty() const { return !head(); }
|
bool is_empty() const { return !head(); }
|
||||||
|
@ -35,8 +35,8 @@ template<typename T>
|
|||||||
class SinglyLinkedListWithCount : private SinglyLinkedList<T> {
|
class SinglyLinkedListWithCount : private SinglyLinkedList<T> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SinglyLinkedListWithCount() { }
|
SinglyLinkedListWithCount() = default;
|
||||||
~SinglyLinkedListWithCount() { }
|
~SinglyLinkedListWithCount() = default;
|
||||||
|
|
||||||
using List = SinglyLinkedList<T>;
|
using List = SinglyLinkedList<T>;
|
||||||
|
|
||||||
|
@ -105,10 +105,7 @@ class Span : public Detail::Span<T> {
|
|||||||
public:
|
public:
|
||||||
using Detail::Span<T>::Span;
|
using Detail::Span<T>::Span;
|
||||||
|
|
||||||
ALWAYS_INLINE constexpr Span(std::nullptr_t)
|
constexpr Span() = default;
|
||||||
: Span()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ALWAYS_INLINE constexpr Span(const Span& other)
|
ALWAYS_INLINE constexpr Span(const Span& other)
|
||||||
: Span(other.m_values, other.m_size)
|
: Span(other.m_values, other.m_size)
|
||||||
|
@ -213,7 +213,7 @@ Vector<StringView> String::split_view(const char separator, bool keep_empty) con
|
|||||||
ByteBuffer String::to_byte_buffer() const
|
ByteBuffer String::to_byte_buffer() const
|
||||||
{
|
{
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
return nullptr;
|
return {};
|
||||||
return ByteBuffer::copy(reinterpret_cast<const u8*>(characters()), length());
|
return ByteBuffer::copy(reinterpret_cast<const u8*>(characters()), length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
AK/String.h
12
AK/String.h
@ -58,9 +58,9 @@ namespace AK {
|
|||||||
|
|
||||||
class String {
|
class String {
|
||||||
public:
|
public:
|
||||||
~String() { }
|
~String() = default;
|
||||||
|
|
||||||
String() { }
|
String() = default;
|
||||||
String(const StringView&);
|
String(const StringView&);
|
||||||
|
|
||||||
String(const String& other)
|
String(const String& other)
|
||||||
@ -153,7 +153,13 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] bool copy_characters_to_buffer(char* buffer, size_t buffer_size) const;
|
[[nodiscard]] bool copy_characters_to_buffer(char* buffer, size_t buffer_size) const;
|
||||||
|
|
||||||
ALWAYS_INLINE ReadonlyBytes bytes() const { return m_impl ? m_impl->bytes() : nullptr; }
|
ALWAYS_INLINE ReadonlyBytes bytes() const
|
||||||
|
{
|
||||||
|
if (m_impl) {
|
||||||
|
return m_impl->bytes();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE const char& operator[](size_t i) const
|
ALWAYS_INLINE const char& operator[](size_t i) const
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
using OutputType = String;
|
using OutputType = String;
|
||||||
|
|
||||||
explicit StringBuilder(size_t initial_capacity = inline_capacity);
|
explicit StringBuilder(size_t initial_capacity = inline_capacity);
|
||||||
~StringBuilder() { }
|
~StringBuilder() = default;
|
||||||
|
|
||||||
void append(const StringView&);
|
void append(const StringView&);
|
||||||
void append(const Utf32View&);
|
void append(const Utf32View&);
|
||||||
|
@ -37,7 +37,7 @@ namespace AK {
|
|||||||
|
|
||||||
class StringView {
|
class StringView {
|
||||||
public:
|
public:
|
||||||
ALWAYS_INLINE constexpr StringView() { }
|
ALWAYS_INLINE constexpr StringView() = default;
|
||||||
ALWAYS_INLINE constexpr StringView(const char* characters, size_t length)
|
ALWAYS_INLINE constexpr StringView(const char* characters, size_t length)
|
||||||
: m_characters(characters)
|
: m_characters(characters)
|
||||||
, m_length(length)
|
, m_length(length)
|
||||||
|
@ -37,7 +37,7 @@ TEST_CASE(sorts_without_copy)
|
|||||||
AK_MAKE_NONCOPYABLE(NoCopy);
|
AK_MAKE_NONCOPYABLE(NoCopy);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NoCopy() { }
|
NoCopy() = default;
|
||||||
NoCopy(NoCopy&&) = default;
|
NoCopy(NoCopy&&) = default;
|
||||||
|
|
||||||
NoCopy& operator=(NoCopy&&) = default;
|
NoCopy& operator=(NoCopy&&) = default;
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
class SimpleWeakable : public Weakable<SimpleWeakable>
|
class SimpleWeakable : public Weakable<SimpleWeakable>
|
||||||
, public RefCounted<SimpleWeakable> {
|
, public RefCounted<SimpleWeakable> {
|
||||||
public:
|
public:
|
||||||
SimpleWeakable() { }
|
SimpleWeakable() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_member { 123 };
|
int m_member { 123 };
|
||||||
|
2
AK/URL.h
2
AK/URL.h
@ -35,7 +35,7 @@ namespace AK {
|
|||||||
|
|
||||||
class URL {
|
class URL {
|
||||||
public:
|
public:
|
||||||
URL() { }
|
URL() = default;
|
||||||
URL(const StringView&);
|
URL(const StringView&);
|
||||||
URL(const char* string)
|
URL(const char* string)
|
||||||
: URL(StringView(string))
|
: URL(StringView(string))
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
UUID();
|
UUID();
|
||||||
UUID(Array<u8, 16> uuid_buffer);
|
UUID(Array<u8, 16> uuid_buffer);
|
||||||
UUID(const StringView&);
|
UUID(const StringView&);
|
||||||
~UUID() { }
|
~UUID() = default;
|
||||||
|
|
||||||
bool operator==(const UUID&) const;
|
bool operator==(const UUID&) const;
|
||||||
bool operator!=(const UUID& other) const { return !(*this == other); }
|
bool operator!=(const UUID& other) const { return !(*this == other); }
|
||||||
|
@ -44,7 +44,7 @@ template<typename T, typename EnableIf<IsPointer<T>::value, int>::Type = 0>
|
|||||||
|
|
||||||
class Userspace {
|
class Userspace {
|
||||||
public:
|
public:
|
||||||
Userspace() { }
|
Userspace() = default;
|
||||||
|
|
||||||
operator bool() const { return m_ptr; }
|
operator bool() const { return m_ptr; }
|
||||||
operator FlatPtr() const { return (FlatPtr)m_ptr; }
|
operator FlatPtr() const { return (FlatPtr)m_ptr; }
|
||||||
|
@ -38,8 +38,8 @@ class Utf32CodepointIterator {
|
|||||||
friend class Utf32View;
|
friend class Utf32View;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Utf32CodepointIterator() { }
|
Utf32CodepointIterator() = default;
|
||||||
~Utf32CodepointIterator() { }
|
~Utf32CodepointIterator() = default;
|
||||||
|
|
||||||
bool operator==(const Utf32CodepointIterator& other) const
|
bool operator==(const Utf32CodepointIterator& other) const
|
||||||
{
|
{
|
||||||
@ -83,7 +83,7 @@ class Utf32View {
|
|||||||
public:
|
public:
|
||||||
using Iterator = Utf32CodepointIterator;
|
using Iterator = Utf32CodepointIterator;
|
||||||
|
|
||||||
Utf32View() { }
|
Utf32View() = default;
|
||||||
Utf32View(const u32* code_points, size_t length)
|
Utf32View(const u32* code_points, size_t length)
|
||||||
: m_code_points(code_points)
|
: m_code_points(code_points)
|
||||||
, m_length(length)
|
, m_length(length)
|
||||||
|
@ -37,8 +37,8 @@ class Utf8CodepointIterator {
|
|||||||
friend class Utf8View;
|
friend class Utf8View;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Utf8CodepointIterator() { }
|
Utf8CodepointIterator() = default;
|
||||||
~Utf8CodepointIterator() { }
|
~Utf8CodepointIterator() = default;
|
||||||
|
|
||||||
bool operator==(const Utf8CodepointIterator&) const;
|
bool operator==(const Utf8CodepointIterator&) const;
|
||||||
bool operator!=(const Utf8CodepointIterator&) const;
|
bool operator!=(const Utf8CodepointIterator&) const;
|
||||||
@ -63,11 +63,11 @@ class Utf8View {
|
|||||||
public:
|
public:
|
||||||
using Iterator = Utf8CodepointIterator;
|
using Iterator = Utf8CodepointIterator;
|
||||||
|
|
||||||
Utf8View() { }
|
Utf8View() = default;
|
||||||
explicit Utf8View(const String&);
|
explicit Utf8View(const String&);
|
||||||
explicit Utf8View(const StringView&);
|
explicit Utf8View(const StringView&);
|
||||||
explicit Utf8View(const char*);
|
explicit Utf8View(const char*);
|
||||||
~Utf8View() { }
|
~Utf8View() = default;
|
||||||
|
|
||||||
const StringView& as_string() const { return m_string; }
|
const StringView& as_string() const { return m_string; }
|
||||||
|
|
||||||
|
12
AK/WeakPtr.h
12
AK/WeakPtr.h
@ -37,8 +37,7 @@ class WeakPtr {
|
|||||||
friend class Weakable;
|
friend class Weakable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WeakPtr() { }
|
WeakPtr() = default;
|
||||||
WeakPtr(std::nullptr_t) { }
|
|
||||||
|
|
||||||
template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
|
template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
|
||||||
WeakPtr(const WeakPtr<U>& other)
|
WeakPtr(const WeakPtr<U>& other)
|
||||||
@ -261,6 +260,15 @@ struct Formatter<WeakPtr<T>> : Formatter<const T*> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
WeakPtr<T> try_make_weak_ptr(const T* ptr)
|
||||||
|
{
|
||||||
|
if (ptr) {
|
||||||
|
return ptr->template make_weak_ptr<T>();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using AK::WeakPtr;
|
using AK::WeakPtr;
|
||||||
|
@ -130,7 +130,7 @@ public:
|
|||||||
WeakPtr<U> make_weak_ptr() const;
|
WeakPtr<U> make_weak_ptr() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Weakable() { }
|
Weakable() = default;
|
||||||
|
|
||||||
~Weakable()
|
~Weakable()
|
||||||
{
|
{
|
||||||
|
@ -445,7 +445,7 @@ TextEditorWidget::TextEditorWidget()
|
|||||||
|
|
||||||
auto& syntax_menu = view_menu.add_submenu("Syntax");
|
auto& syntax_menu = view_menu.add_submenu("Syntax");
|
||||||
m_plain_text_highlight = GUI::Action::create_checkable("Plain text", [&](auto&) {
|
m_plain_text_highlight = GUI::Action::create_checkable("Plain text", [&](auto&) {
|
||||||
m_editor->set_syntax_highlighter(nullptr);
|
m_editor->set_syntax_highlighter({});
|
||||||
m_editor->update();
|
m_editor->update();
|
||||||
});
|
});
|
||||||
m_plain_text_highlight->set_checked(true);
|
m_plain_text_highlight->set_checked(true);
|
||||||
|
@ -436,7 +436,7 @@ void Editor::set_document(GUI::TextDocument& doc)
|
|||||||
m_language_client = get_language_client<LanguageClients::Shell::ServerConnection>(project().root_path());
|
m_language_client = get_language_client<LanguageClients::Shell::ServerConnection>(project().root_path());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
set_syntax_highlighter(nullptr);
|
set_syntax_highlighter({});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_language_client) {
|
if (m_language_client) {
|
||||||
|
@ -43,7 +43,7 @@ Project::~Project()
|
|||||||
OwnPtr<Project> Project::open_with_root_path(const String& root_path)
|
OwnPtr<Project> Project::open_with_root_path(const String& root_path)
|
||||||
{
|
{
|
||||||
if (!Core::File::is_directory(root_path))
|
if (!Core::File::is_directory(root_path))
|
||||||
return nullptr;
|
return {};
|
||||||
return adopt_own(*new Project(root_path));
|
return adopt_own(*new Project(root_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,13 +337,13 @@ public:
|
|||||||
parameter_generator.append(R"~~~(
|
parameter_generator.append(R"~~~(
|
||||||
@parameter.type@ @parameter.name@ = @parameter.initial_value@;
|
@parameter.type@ @parameter.name@ = @parameter.initial_value@;
|
||||||
if (!decoder.decode(@parameter.name@))
|
if (!decoder.decode(@parameter.name@))
|
||||||
return nullptr;
|
return {};
|
||||||
)~~~");
|
)~~~");
|
||||||
|
|
||||||
if (parameter.attributes.contains_slow("UTF8")) {
|
if (parameter.attributes.contains_slow("UTF8")) {
|
||||||
parameter_generator.append(R"~~~(
|
parameter_generator.append(R"~~~(
|
||||||
if (!Utf8View(@parameter.name@).validate())
|
if (!Utf8View(@parameter.name@).validate())
|
||||||
return nullptr;
|
return {};
|
||||||
)~~~");
|
)~~~");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,7 +449,7 @@ public:
|
|||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
#endif
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message_endpoint_magic != @endpoint.magic@) {
|
if (message_endpoint_magic != @endpoint.magic@) {
|
||||||
@ -460,7 +460,7 @@ public:
|
|||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
#endif
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 message_id = 0;
|
i32 message_id = 0;
|
||||||
@ -473,7 +473,7 @@ public:
|
|||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
#endif
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
OwnPtr<IPC::Message> message;
|
OwnPtr<IPC::Message> message;
|
||||||
@ -507,7 +507,7 @@ public:
|
|||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
#endif
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream.handle_any_error()) {
|
if (stream.handle_any_error()) {
|
||||||
@ -518,7 +518,7 @@ public:
|
|||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
#endif
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
@ -543,7 +543,7 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
message_generator.append(R"~~~(
|
message_generator.append(R"~~~(
|
||||||
handle(static_cast<const Messages::@endpoint.name@::@message.name@&>(message));
|
handle(static_cast<const Messages::@endpoint.name@::@message.name@&>(message));
|
||||||
return nullptr;
|
return {};
|
||||||
)~~~");
|
)~~~");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -553,7 +553,7 @@ public:
|
|||||||
}
|
}
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)~~~");
|
)~~~");
|
||||||
|
@ -368,7 +368,7 @@ Profile::LibraryMetadata::LibraryMetadata(JsonArray regions)
|
|||||||
|
|
||||||
auto file_or_error = MappedFile::map(path);
|
auto file_or_error = MappedFile::map(path);
|
||||||
if (file_or_error.is_error()) {
|
if (file_or_error.is_error()) {
|
||||||
m_libraries.set(name, nullptr);
|
m_libraries.set(name, {});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto elf = ELF::Image(file_or_error.value()->bytes());
|
auto elf = ELF::Image(file_or_error.value()->bytes());
|
||||||
|
@ -41,7 +41,7 @@ OwnPtr<MultiProcessorParser> MultiProcessorParser::autodetect()
|
|||||||
{
|
{
|
||||||
auto floating_pointer = find_floating_pointer();
|
auto floating_pointer = find_floating_pointer();
|
||||||
if (!floating_pointer.has_value())
|
if (!floating_pointer.has_value())
|
||||||
return nullptr;
|
return {};
|
||||||
return adopt_own(*new MultiProcessorParser(floating_pointer.value()));
|
return adopt_own(*new MultiProcessorParser(floating_pointer.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ OwnPtr<CoreDump> CoreDump::create(NonnullRefPtr<Process> process, const String&
|
|||||||
{
|
{
|
||||||
if (!process->is_dumpable()) {
|
if (!process->is_dumpable()) {
|
||||||
dbgln("Refusing to generate CoreDump for non-dumpable process {}", process->pid().value());
|
dbgln("Refusing to generate CoreDump for non-dumpable process {}", process->pid().value());
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fd = create_target_file(process, output_path);
|
auto fd = create_target_file(process, output_path);
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return nullptr;
|
return {};
|
||||||
return adopt_own(*new CoreDump(move(process), fd.release_nonnull()));
|
return adopt_own(*new CoreDump(move(process), fd.release_nonnull()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ void SB16::handle_irq(const RegisterState&)
|
|||||||
|
|
||||||
void SB16::wait_for_irq()
|
void SB16::wait_for_irq()
|
||||||
{
|
{
|
||||||
m_irq_queue.wait_on(nullptr, "SB16");
|
m_irq_queue.wait_on({}, "SB16");
|
||||||
disable_irq();
|
disable_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction_blocking(FIFO::Di
|
|||||||
|
|
||||||
if (m_writers == 0) {
|
if (m_writers == 0) {
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
m_write_open_queue.wait_on(nullptr, "FIFO");
|
m_write_open_queue.wait_on({}, "FIFO");
|
||||||
locker.lock();
|
locker.lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction_blocking(FIFO::Di
|
|||||||
|
|
||||||
if (m_readers == 0) {
|
if (m_readers == 0) {
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
m_read_open_queue.wait_on(nullptr, "FIFO");
|
m_read_open_queue.wait_on({}, "FIFO");
|
||||||
locker.lock();
|
locker.lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ KResult Plan9FS::post_message(Message& message, RefPtr<ReceiveCompletion> comple
|
|||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
if (!description.can_write()) {
|
if (!description.can_write()) {
|
||||||
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
||||||
if (Thread::current()->block<Thread::WriteBlocker>(nullptr, description, unblock_flags).was_interrupted())
|
if (Thread::current()->block<Thread::WriteBlocker>({}, description, unblock_flags).was_interrupted())
|
||||||
return KResult(-EINTR);
|
return KResult(-EINTR);
|
||||||
}
|
}
|
||||||
auto data_buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>(data));
|
auto data_buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>(data));
|
||||||
@ -552,7 +552,7 @@ KResult Plan9FS::do_read(u8* data, size_t size)
|
|||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
if (!description.can_read()) {
|
if (!description.can_read()) {
|
||||||
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
||||||
if (Thread::current()->block<Thread::ReadBlocker>(nullptr, description, unblock_flags).was_interrupted())
|
if (Thread::current()->block<Thread::ReadBlocker>({}, description, unblock_flags).was_interrupted())
|
||||||
return KResult(-EINTR);
|
return KResult(-EINTR);
|
||||||
}
|
}
|
||||||
auto data_buffer = UserOrKernelBuffer::for_kernel_buffer(data);
|
auto data_buffer = UserOrKernelBuffer::for_kernel_buffer(data);
|
||||||
@ -621,7 +621,7 @@ KResult Plan9FS::post_message_and_wait_for_a_reply(Message& message)
|
|||||||
auto result = post_message(message, completion);
|
auto result = post_message(message, completion);
|
||||||
if (result.is_error())
|
if (result.is_error())
|
||||||
return result;
|
return result;
|
||||||
if (Thread::current()->block<Plan9FS::Blocker>(nullptr, *this, message, completion).was_interrupted())
|
if (Thread::current()->block<Plan9FS::Blocker>({}, *this, message, completion).was_interrupted())
|
||||||
return KResult(-EINTR);
|
return KResult(-EINTR);
|
||||||
|
|
||||||
if (completion->result.is_error()) {
|
if (completion->result.is_error()) {
|
||||||
|
@ -128,7 +128,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto impl = KBufferImpl::try_create_with_size(size, access, name, strategy);
|
auto impl = KBufferImpl::try_create_with_size(size, access, name, strategy);
|
||||||
if (!impl)
|
if (!impl)
|
||||||
return nullptr;
|
return {};
|
||||||
return adopt_own(*new KBuffer(impl.release_nonnull()));
|
return adopt_own(*new KBuffer(impl.release_nonnull()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto impl = KBufferImpl::try_create_with_bytes(bytes, access, name, strategy);
|
auto impl = KBufferImpl::try_create_with_bytes(bytes, access, name, strategy);
|
||||||
if (!impl)
|
if (!impl)
|
||||||
return nullptr;
|
return {};
|
||||||
return adopt_own(*new KBuffer(impl.release_nonnull()));
|
return adopt_own(*new KBuffer(impl.release_nonnull()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ void Lock::lock(Mode mode)
|
|||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
m_lock.store(false, AK::memory_order_release);
|
m_lock.store(false, AK::memory_order_release);
|
||||||
} while (m_queue.wait_on(nullptr, m_name) == Thread::BlockResult::NotBlocked);
|
} while (m_queue.wait_on({}, m_name) == Thread::BlockResult::NotBlocked);
|
||||||
} else {
|
} else {
|
||||||
// I don't know *who* is using "m_lock", so just yield.
|
// I don't know *who* is using "m_lock", so just yield.
|
||||||
Scheduler::yield_from_critical();
|
Scheduler::yield_from_critical();
|
||||||
|
@ -457,7 +457,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||||||
sti();
|
sti();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_wait_queue.wait_on(nullptr, "E1000NetworkAdapter");
|
m_wait_queue.wait_on({}, "E1000NetworkAdapter");
|
||||||
}
|
}
|
||||||
#ifdef E1000_DEBUG
|
#ifdef E1000_DEBUG
|
||||||
dbgln("E1000: Sent packet, status is now {:#02x}!", (u8)descriptor.status);
|
dbgln("E1000: Sent packet, status is now {:#02x}!", (u8)descriptor.status);
|
||||||
|
@ -255,7 +255,7 @@ KResultOr<size_t> IPv4Socket::receive_byte_buffered(FileDescription& description
|
|||||||
|
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
auto unblocked_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
|
auto unblocked_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
|
||||||
auto res = Thread::current()->block<Thread::ReadBlocker>(nullptr, description, unblocked_flags);
|
auto res = Thread::current()->block<Thread::ReadBlocker>({}, description, unblocked_flags);
|
||||||
locker.lock();
|
locker.lock();
|
||||||
|
|
||||||
if (!((u32)unblocked_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Read)) {
|
if (!((u32)unblocked_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Read)) {
|
||||||
@ -306,7 +306,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
|
|||||||
|
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
auto unblocked_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
|
auto unblocked_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
|
||||||
auto res = Thread::current()->block<Thread::ReadBlocker>(nullptr, description, unblocked_flags);
|
auto res = Thread::current()->block<Thread::ReadBlocker>({}, description, unblocked_flags);
|
||||||
locker.lock();
|
locker.lock();
|
||||||
|
|
||||||
if (!((u32)unblocked_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Read)) {
|
if (!((u32)unblocked_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Read)) {
|
||||||
|
@ -192,7 +192,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto unblock_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
|
auto unblock_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
|
||||||
if (Thread::current()->block<Thread::ConnectBlocker>(nullptr, description, unblock_flags).was_interrupted()) {
|
if (Thread::current()->block<Thread::ConnectBlocker>({}, description, unblock_flags).was_interrupted()) {
|
||||||
set_connect_side_role(Role::None);
|
set_connect_side_role(Role::None);
|
||||||
return KResult(-EINTR);
|
return KResult(-EINTR);
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ KResultOr<size_t> LocalSocket::recvfrom(FileDescription& description, UserOrKern
|
|||||||
}
|
}
|
||||||
} else if (!can_read(description, 0)) {
|
} else if (!can_read(description, 0)) {
|
||||||
auto unblock_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
|
auto unblock_flags = Thread::FileDescriptionBlocker::BlockFlags::None;
|
||||||
if (Thread::current()->block<Thread::ReadBlocker>(nullptr, description, unblock_flags).was_interrupted())
|
if (Thread::current()->block<Thread::ReadBlocker>({}, description, unblock_flags).was_interrupted())
|
||||||
return KResult(-EINTR);
|
return KResult(-EINTR);
|
||||||
}
|
}
|
||||||
if (!has_attached_peer(description) && socket_buffer->is_empty())
|
if (!has_attached_peer(description) && socket_buffer->is_empty())
|
||||||
|
@ -114,7 +114,7 @@ void NetworkTask_main(void*)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
size_t packet_size = dequeue_packet(buffer, buffer_size, packet_timestamp);
|
size_t packet_size = dequeue_packet(buffer, buffer_size, packet_timestamp);
|
||||||
if (!packet_size) {
|
if (!packet_size) {
|
||||||
packet_wait_queue.wait_on(nullptr, "NetworkTask");
|
packet_wait_queue.wait_on({}, "NetworkTask");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (packet_size < sizeof(EthernetFrameHeader)) {
|
if (packet_size < sizeof(EthernetFrameHeader)) {
|
||||||
|
@ -230,7 +230,7 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
|
|||||||
adapter->send({ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, request);
|
adapter->send({ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, request);
|
||||||
|
|
||||||
Optional<MACAddress> addr;
|
Optional<MACAddress> addr;
|
||||||
if (!Thread::current()->block<ARPTableBlocker>(nullptr, next_hop_ip, addr).was_interrupted()) {
|
if (!Thread::current()->block<ARPTableBlocker>({}, next_hop_ip, addr).was_interrupted()) {
|
||||||
if (addr.has_value()) {
|
if (addr.has_value()) {
|
||||||
#ifdef ROUTING_DEBUG
|
#ifdef ROUTING_DEBUG
|
||||||
klog() << "Routing: Got ARP response using adapter " << adapter->name().characters() << " for " << next_hop_ip.to_string().characters() << " (" << addr.value().to_string().characters() << ")";
|
klog() << "Routing: Got ARP response using adapter " << adapter->name().characters() << " for " << next_hop_ip.to_string().characters() << " (" << addr.value().to_string().characters() << ")";
|
||||||
|
@ -400,7 +400,7 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
|
|||||||
if (should_block == ShouldBlock::Yes) {
|
if (should_block == ShouldBlock::Yes) {
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
||||||
if (Thread::current()->block<Thread::ConnectBlocker>(nullptr, description, unblock_flags).was_interrupted())
|
if (Thread::current()->block<Thread::ConnectBlocker>({}, description, unblock_flags).was_interrupted())
|
||||||
return KResult(-EINTR);
|
return KResult(-EINTR);
|
||||||
locker.lock();
|
locker.lock();
|
||||||
ASSERT(setup_state() == SetupState::Completed);
|
ASSERT(setup_state() == SetupState::Completed);
|
||||||
|
@ -89,7 +89,7 @@ OwnPtr<KBuffer> PerformanceEventBuffer::to_json(ProcessID pid, const String& exe
|
|||||||
{
|
{
|
||||||
KBufferBuilder builder;
|
KBufferBuilder builder;
|
||||||
if (!to_json(builder, pid, executable_path))
|
if (!to_json(builder, pid, executable_path))
|
||||||
return nullptr;
|
return {};
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ KernelRng::KernelRng()
|
|||||||
void KernelRng::wait_for_entropy()
|
void KernelRng::wait_for_entropy()
|
||||||
{
|
{
|
||||||
if (!resource().is_ready()) {
|
if (!resource().is_ready()) {
|
||||||
m_seed_queue.wait_on(nullptr, "KernelRng");
|
m_seed_queue.wait_on({}, "KernelRng");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ OwnPtr<MBRPartitionTable> MBRPartitionTable::try_to_initialize(const StorageDevi
|
|||||||
{
|
{
|
||||||
auto table = make<MBRPartitionTable>(device, start_lba);
|
auto table = make<MBRPartitionTable>(device, start_lba);
|
||||||
if (!table->is_valid())
|
if (!table->is_valid())
|
||||||
return nullptr;
|
return {};
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,16 +90,16 @@ OwnPtr<PartitionTable> StorageManagement::try_to_initialize_partition_table(cons
|
|||||||
if (mbr_table_or_result.error() == PartitionTable::Error::MBRProtective) {
|
if (mbr_table_or_result.error() == PartitionTable::Error::MBRProtective) {
|
||||||
auto gpt_table_or_result = GUIDPartitionTable::try_to_initialize(device);
|
auto gpt_table_or_result = GUIDPartitionTable::try_to_initialize(device);
|
||||||
if (gpt_table_or_result.is_error())
|
if (gpt_table_or_result.is_error())
|
||||||
return nullptr;
|
return {};
|
||||||
return move(gpt_table_or_result.value());
|
return move(gpt_table_or_result.value());
|
||||||
}
|
}
|
||||||
if (mbr_table_or_result.error() == PartitionTable::Error::ConatinsEBR) {
|
if (mbr_table_or_result.error() == PartitionTable::Error::ConatinsEBR) {
|
||||||
auto ebr_table_or_result = EBRPartitionTable::try_to_initialize(device);
|
auto ebr_table_or_result = EBRPartitionTable::try_to_initialize(device);
|
||||||
if (ebr_table_or_result.is_error())
|
if (ebr_table_or_result.is_error())
|
||||||
return nullptr;
|
return {};
|
||||||
return move(ebr_table_or_result.value());
|
return move(ebr_table_or_result.value());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtrVector<DiskPartition> StorageManagement::enumerate_disk_partitions() const
|
NonnullRefPtrVector<DiskPartition> StorageManagement::enumerate_disk_partitions() const
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/ScopeGuard.h>
|
#include <AK/ScopeGuard.h>
|
||||||
#include <AK/TemporaryChange.h>
|
#include <AK/TemporaryChange.h>
|
||||||
|
#include <AK/WeakPtr.h>
|
||||||
#include <Kernel/FileSystem/Custody.h>
|
#include <Kernel/FileSystem/Custody.h>
|
||||||
#include <Kernel/FileSystem/FileDescription.h>
|
#include <Kernel/FileSystem/FileDescription.h>
|
||||||
#include <Kernel/PerformanceEventBuffer.h>
|
#include <Kernel/PerformanceEventBuffer.h>
|
||||||
@ -269,7 +270,7 @@ KResultOr<Process::LoadResult> Process::load_elf_object(FileDescription& object_
|
|||||||
executable_size,
|
executable_size,
|
||||||
VirtualAddress(elf_image.program_header_table_offset()).offset(load_offset).get(),
|
VirtualAddress(elf_image.program_header_table_offset()).offset(load_offset).get(),
|
||||||
elf_image.program_header_count(),
|
elf_image.program_header_count(),
|
||||||
master_tls_region ? master_tls_region->make_weak_ptr() : nullptr,
|
AK::try_make_weak_ptr(master_tls_region),
|
||||||
master_tls_size,
|
master_tls_size,
|
||||||
master_tls_alignment,
|
master_tls_alignment,
|
||||||
stack_region->make_weak_ptr()
|
stack_region->make_weak_ptr()
|
||||||
|
@ -51,7 +51,7 @@ ssize_t Process::sys$read(int fd, Userspace<u8*> buffer, ssize_t size)
|
|||||||
if (description->is_blocking()) {
|
if (description->is_blocking()) {
|
||||||
if (!description->can_read()) {
|
if (!description->can_read()) {
|
||||||
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
||||||
if (Thread::current()->block<Thread::ReadBlocker>(nullptr, *description, unblock_flags).was_interrupted())
|
if (Thread::current()->block<Thread::ReadBlocker>({}, *description, unblock_flags).was_interrupted())
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
if (!((u32)unblock_flags & (u32)Thread::FileBlocker::BlockFlags::Read))
|
if (!((u32)unblock_flags & (u32)Thread::FileBlocker::BlockFlags::Read))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
@ -115,7 +115,7 @@ int Process::sys$accept(int accepting_socket_fd, Userspace<sockaddr*> user_addre
|
|||||||
if (!socket.can_accept()) {
|
if (!socket.can_accept()) {
|
||||||
if (accepting_socket_description->is_blocking()) {
|
if (accepting_socket_description->is_blocking()) {
|
||||||
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
||||||
if (Thread::current()->block<Thread::AcceptBlocker>(nullptr, *accepting_socket_description, unblock_flags).was_interrupted())
|
if (Thread::current()->block<Thread::AcceptBlocker>({}, *accepting_socket_description, unblock_flags).was_interrupted())
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
} else {
|
} else {
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
@ -132,7 +132,7 @@ int Process::sys$join_thread(pid_t tid, Userspace<void**> exit_value)
|
|||||||
// NOTE: pthread_join() cannot be interrupted by signals. Only by death.
|
// NOTE: pthread_join() cannot be interrupted by signals. Only by death.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
KResult try_join_result(KSuccess);
|
KResult try_join_result(KSuccess);
|
||||||
auto result = current_thread->block<Thread::JoinBlocker>(nullptr, *thread, try_join_result, joinee_exit_value);
|
auto result = current_thread->block<Thread::JoinBlocker>({}, *thread, try_join_result, joinee_exit_value);
|
||||||
if (result == Thread::BlockResult::NotBlocked) {
|
if (result == Thread::BlockResult::NotBlocked) {
|
||||||
if (try_join_result.is_error())
|
if (try_join_result.is_error())
|
||||||
return try_join_result.error();
|
return try_join_result.error();
|
||||||
|
@ -42,7 +42,7 @@ KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<siginfo_t> result = KResult(KSuccess);
|
KResultOr<siginfo_t> result = KResult(KSuccess);
|
||||||
if (Thread::current()->block<Thread::WaitBlocker>(nullptr, options, idtype, id, result).was_interrupted())
|
if (Thread::current()->block<Thread::WaitBlocker>({}, options, idtype, id, result).was_interrupted())
|
||||||
return KResult(-EINTR);
|
return KResult(-EINTR);
|
||||||
ASSERT(!result.is_error() || (options & WNOHANG) || result.error() != KSuccess);
|
ASSERT(!result.is_error() || (options & WNOHANG) || result.error() != KSuccess);
|
||||||
return result;
|
return result;
|
||||||
|
@ -97,7 +97,7 @@ ssize_t Process::do_write(FileDescription& description, const UserOrKernelBuffer
|
|||||||
return total_nwritten;
|
return total_nwritten;
|
||||||
}
|
}
|
||||||
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
auto unblock_flags = Thread::FileBlocker::BlockFlags::None;
|
||||||
if (Thread::current()->block<Thread::WriteBlocker>(nullptr, description, unblock_flags).was_interrupted()) {
|
if (Thread::current()->block<Thread::WriteBlocker>({}, description, unblock_flags).was_interrupted()) {
|
||||||
if (total_nwritten == 0)
|
if (total_nwritten == 0)
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ void FinalizerTask::spawn()
|
|||||||
finalizer_thread, "FinalizerTask", [](void*) {
|
finalizer_thread, "FinalizerTask", [](void*) {
|
||||||
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
|
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
g_finalizer_wait_queue->wait_on(nullptr, "FinalizerTask");
|
g_finalizer_wait_queue->wait_on({}, "FinalizerTask");
|
||||||
|
|
||||||
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
|
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
|
||||||
Thread::finalize_dying_threads();
|
Thread::finalize_dying_threads();
|
||||||
|
@ -316,13 +316,13 @@ void Thread::relock_process(LockMode previous_locked, u32 lock_count_to_restore)
|
|||||||
auto Thread::sleep(clockid_t clock_id, const timespec& duration, timespec* remaining_time) -> BlockResult
|
auto Thread::sleep(clockid_t clock_id, const timespec& duration, timespec* remaining_time) -> BlockResult
|
||||||
{
|
{
|
||||||
ASSERT(state() == Thread::Running);
|
ASSERT(state() == Thread::Running);
|
||||||
return Thread::current()->block<Thread::SleepBlocker>(nullptr, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time);
|
return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Thread::sleep_until(clockid_t clock_id, const timespec& deadline) -> BlockResult
|
auto Thread::sleep_until(clockid_t clock_id, const timespec& deadline) -> BlockResult
|
||||||
{
|
{
|
||||||
ASSERT(state() == Thread::Running);
|
ASSERT(state() == Thread::Running);
|
||||||
return Thread::current()->block<Thread::SleepBlocker>(nullptr, Thread::BlockTimeout(true, &deadline, nullptr, clock_id));
|
return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(true, &deadline, nullptr, clock_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Thread::state_string() const
|
const char* Thread::state_string() const
|
||||||
|
@ -207,10 +207,6 @@ public:
|
|||||||
: m_infinite(true)
|
: m_infinite(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
BlockTimeout(std::nullptr_t)
|
|
||||||
: m_infinite(true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
explicit BlockTimeout(bool is_absolute, const timeval* time, const timespec* start_time = nullptr, clockid_t clock_id = CLOCK_MONOTONIC_COARSE)
|
explicit BlockTimeout(bool is_absolute, const timeval* time, const timespec* start_time = nullptr, clockid_t clock_id = CLOCK_MONOTONIC_COARSE)
|
||||||
: m_clock_id(clock_id)
|
: m_clock_id(clock_id)
|
||||||
, m_infinite(!time)
|
, m_infinite(!time)
|
||||||
|
@ -385,7 +385,7 @@ OwnPtr<Region> MemoryManager::allocate_contiguous_kernel_region(size_t size, con
|
|||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
||||||
if (!range.is_valid())
|
if (!range.is_valid())
|
||||||
return nullptr;
|
return {};
|
||||||
auto vmobject = ContiguousVMObject::create_with_size(size);
|
auto vmobject = ContiguousVMObject::create_with_size(size);
|
||||||
return allocate_kernel_region_with_vmobject(range, vmobject, name, access, user_accessible, cacheable);
|
return allocate_kernel_region_with_vmobject(range, vmobject, name, access, user_accessible, cacheable);
|
||||||
}
|
}
|
||||||
@ -396,10 +396,10 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(size_t size, const StringVi
|
|||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
||||||
if (!range.is_valid())
|
if (!range.is_valid())
|
||||||
return nullptr;
|
return {};
|
||||||
auto vmobject = AnonymousVMObject::create_with_size(size, strategy);
|
auto vmobject = AnonymousVMObject::create_with_size(size, strategy);
|
||||||
if (!vmobject)
|
if (!vmobject)
|
||||||
return nullptr;
|
return {};
|
||||||
return allocate_kernel_region_with_vmobject(range, vmobject.release_nonnull(), name, access, user_accessible, cacheable);
|
return allocate_kernel_region_with_vmobject(range, vmobject.release_nonnull(), name, access, user_accessible, cacheable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,10 +409,10 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(PhysicalAddress paddr, size
|
|||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
||||||
if (!range.is_valid())
|
if (!range.is_valid())
|
||||||
return nullptr;
|
return {};
|
||||||
auto vmobject = AnonymousVMObject::create_for_physical_range(paddr, size);
|
auto vmobject = AnonymousVMObject::create_for_physical_range(paddr, size);
|
||||||
if (!vmobject)
|
if (!vmobject)
|
||||||
return nullptr;
|
return {};
|
||||||
return allocate_kernel_region_with_vmobject(range, *vmobject, name, access, user_accessible, cacheable);
|
return allocate_kernel_region_with_vmobject(range, *vmobject, name, access, user_accessible, cacheable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,10 +422,10 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region_identity(PhysicalAddress pa
|
|||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
auto range = kernel_page_directory().identity_range_allocator().allocate_specific(VirtualAddress(paddr.get()), size);
|
auto range = kernel_page_directory().identity_range_allocator().allocate_specific(VirtualAddress(paddr.get()), size);
|
||||||
if (!range.is_valid())
|
if (!range.is_valid())
|
||||||
return nullptr;
|
return {};
|
||||||
auto vmobject = AnonymousVMObject::create_for_physical_range(paddr, size);
|
auto vmobject = AnonymousVMObject::create_for_physical_range(paddr, size);
|
||||||
if (!vmobject)
|
if (!vmobject)
|
||||||
return nullptr;
|
return {};
|
||||||
return allocate_kernel_region_with_vmobject(range, *vmobject, name, access, user_accessible, cacheable);
|
return allocate_kernel_region_with_vmobject(range, *vmobject, name, access, user_accessible, cacheable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region_with_vmobject(VMObject& vmo
|
|||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
||||||
if (!range.is_valid())
|
if (!range.is_valid())
|
||||||
return nullptr;
|
return {};
|
||||||
return allocate_kernel_region_with_vmobject(range, vmobject, name, access, user_accessible, cacheable);
|
return allocate_kernel_region_with_vmobject(range, vmobject, name, access, user_accessible, cacheable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/WeakPtr.h>
|
||||||
#include <LibCore/Event.h>
|
#include <LibCore/Event.h>
|
||||||
#include <LibCore/Object.h>
|
#include <LibCore/Object.h>
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ namespace Core {
|
|||||||
ChildEvent::ChildEvent(Type type, Object& child, Object* insertion_before_child)
|
ChildEvent::ChildEvent(Type type, Object& child, Object* insertion_before_child)
|
||||||
: Core::Event(type)
|
: Core::Event(type)
|
||||||
, m_child(child.make_weak_ptr())
|
, m_child(child.make_weak_ptr())
|
||||||
, m_insertion_before_child(insertion_before_child ? insertion_before_child->make_weak_ptr() : nullptr)
|
, m_insertion_before_child(AK::try_make_weak_ptr(insertion_before_child))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ bool SignalHandlers::remove(int handler_id)
|
|||||||
auto it = m_handlers.find(handler_id);
|
auto it = m_handlers.find(handler_id);
|
||||||
if (it != m_handlers.end()) {
|
if (it != m_handlers.end()) {
|
||||||
// Mark pending remove
|
// Mark pending remove
|
||||||
m_handlers_pending.set(handler_id, nullptr);
|
m_handlers_pending.set(handler_id, {});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
it = m_handlers_pending.find(handler_id);
|
it = m_handlers_pending.find(handler_id);
|
||||||
|
@ -256,7 +256,7 @@ const LogStream& operator<<(const LogStream&, const Object&);
|
|||||||
register_property( \
|
register_property( \
|
||||||
property_name, \
|
property_name, \
|
||||||
[this] { return this->getter(); }, \
|
[this] { return this->getter(); }, \
|
||||||
nullptr);
|
{});
|
||||||
|
|
||||||
#define REGISTER_RECT_PROPERTY(property_name, getter, setter) \
|
#define REGISTER_RECT_PROPERTY(property_name, getter, setter) \
|
||||||
register_property( \
|
register_property( \
|
||||||
|
@ -37,7 +37,7 @@ OwnPtr<Reader> Reader::create(const String& path)
|
|||||||
{
|
{
|
||||||
auto file_or_error = MappedFile::map(path);
|
auto file_or_error = MappedFile::map(path);
|
||||||
if (file_or_error.is_error())
|
if (file_or_error.is_error())
|
||||||
return nullptr;
|
return {};
|
||||||
return adopt_own(*new Reader(file_or_error.release_value()));
|
return adopt_own(*new Reader(file_or_error.release_value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,12 +90,12 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(const String& command, String
|
|||||||
|
|
||||||
if (waitpid(pid, nullptr, WSTOPPED) != pid) {
|
if (waitpid(pid, nullptr, WSTOPPED) != pid) {
|
||||||
perror("waitpid");
|
perror("waitpid");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptrace(PT_ATTACH, pid, 0, 0) < 0) {
|
if (ptrace(PT_ATTACH, pid, 0, 0) < 0) {
|
||||||
perror("PT_ATTACH");
|
perror("PT_ATTACH");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to continue until the exit from the 'execve' sycsall.
|
// We want to continue until the exit from the 'execve' sycsall.
|
||||||
@ -105,7 +105,7 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(const String& command, String
|
|||||||
|
|
||||||
if (waitpid(pid, nullptr, WSTOPPED) != pid) {
|
if (waitpid(pid, nullptr, WSTOPPED) != pid) {
|
||||||
perror("wait_pid");
|
perror("wait_pid");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto debug_session = adopt_own(*new DebugSession(pid, source_root));
|
auto debug_session = adopt_own(*new DebugSession(pid, source_root));
|
||||||
@ -114,7 +114,7 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(const String& command, String
|
|||||||
int wstatus = debug_session->continue_debuggee_and_wait();
|
int wstatus = debug_session->continue_debuggee_and_wait();
|
||||||
if (WSTOPSIG(wstatus) != SIGTRAP) {
|
if (WSTOPSIG(wstatus) != SIGTRAP) {
|
||||||
dbgln("expected SIGTRAP");
|
dbgln("expected SIGTRAP");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, libraries should have been loaded
|
// At this point, libraries should have been loaded
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/WeakPtr.h>
|
||||||
#include <LibGUI/AboutDialog.h>
|
#include <LibGUI/AboutDialog.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/ActionGroup.h>
|
#include <LibGUI/ActionGroup.h>
|
||||||
@ -39,7 +40,7 @@ namespace CommonActions {
|
|||||||
|
|
||||||
NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_icon, Window* parent)
|
NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_icon, Window* parent)
|
||||||
{
|
{
|
||||||
WeakPtr<Window> weak_parent = parent ? parent->make_weak_ptr<Window>() : nullptr;
|
auto weak_parent = AK::try_make_weak_ptr<Window>(parent);
|
||||||
return Action::create(String::formatted("About {}", app_name), app_icon.bitmap_for_size(16), [=](auto&) {
|
return Action::create(String::formatted("About {}", app_name), app_icon.bitmap_for_size(16), [=](auto&) {
|
||||||
AboutDialog::show(app_name, app_icon.bitmap_for_size(32), weak_parent.ptr());
|
AboutDialog::show(app_name, app_icon.bitmap_for_size(32), weak_parent.ptr());
|
||||||
});
|
});
|
||||||
@ -288,7 +289,7 @@ void Action::set_checked(bool checked)
|
|||||||
|
|
||||||
void Action::set_group(Badge<ActionGroup>, ActionGroup* group)
|
void Action::set_group(Badge<ActionGroup>, ActionGroup* group)
|
||||||
{
|
{
|
||||||
m_action_group = group ? group->make_weak_ptr() : nullptr;
|
m_action_group = AK::try_make_weak_ptr(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::set_icon(const Gfx::Bitmap* icon)
|
void Action::set_icon(const Gfx::Bitmap* icon)
|
||||||
|
@ -171,7 +171,7 @@ protected:
|
|||||||
if (!drain_messages_from_peer())
|
if (!drain_messages_from_peer())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool drain_messages_from_peer()
|
bool drain_messages_from_peer()
|
||||||
|
@ -43,7 +43,7 @@ void ArrayBufferPrototype::initialize(GlobalObject& global_object)
|
|||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function(vm.names.slice, slice, 2, attr);
|
define_native_function(vm.names.slice, slice, 2, attr);
|
||||||
// FIXME: This should be an accessor property
|
// FIXME: This should be an accessor property
|
||||||
define_native_property(vm.names.byteLength, byte_length_getter, nullptr, Attribute::Configurable);
|
define_native_property(vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable);
|
||||||
|
|
||||||
define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), "ArrayBuffer"), Attribute::Configurable);
|
define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), "ArrayBuffer"), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ void ErrorPrototype::initialize(GlobalObject& global_object)
|
|||||||
Object::initialize(global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_property(vm.names.name, name_getter, name_setter, attr);
|
define_native_property(vm.names.name, name_getter, name_setter, attr);
|
||||||
define_native_property(vm.names.message, message_getter, nullptr, attr);
|
define_native_property(vm.names.message, message_getter, {}, attr);
|
||||||
define_native_function(vm.names.toString, to_string, 0, attr);
|
define_native_function(vm.names.toString, to_string, 0, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,11 +50,11 @@ void RegExpPrototype::initialize(GlobalObject& global_object)
|
|||||||
define_native_function(vm.names.exec, exec, 1, attr);
|
define_native_function(vm.names.exec, exec, 1, attr);
|
||||||
|
|
||||||
u8 readable_attr = Attribute::Configurable;
|
u8 readable_attr = Attribute::Configurable;
|
||||||
define_native_property(vm.names.flags, flags, nullptr, readable_attr);
|
define_native_property(vm.names.flags, flags, {}, readable_attr);
|
||||||
define_native_property(vm.names.source, source, nullptr, readable_attr);
|
define_native_property(vm.names.source, source, {}, readable_attr);
|
||||||
|
|
||||||
#define __JS_ENUMERATE(flagName, flag_name, flag_char, ECMAScriptFlagName) \
|
#define __JS_ENUMERATE(flagName, flag_name, flag_char, ECMAScriptFlagName) \
|
||||||
define_native_property(vm.names.flagName, flag_name, nullptr, readable_attr);
|
define_native_property(vm.names.flagName, flag_name, {}, readable_attr);
|
||||||
JS_ENUMERATE_REGEXP_FLAGS
|
JS_ENUMERATE_REGEXP_FLAGS
|
||||||
#undef __JS_ENUMERATE
|
#undef __JS_ENUMERATE
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ void ScriptFunction::initialize(GlobalObject& global_object)
|
|||||||
prototype->define_property(vm.names.constructor, this, Attribute::Writable | Attribute::Configurable);
|
prototype->define_property(vm.names.constructor, this, Attribute::Writable | Attribute::Configurable);
|
||||||
define_property(vm.names.prototype, prototype, Attribute::Writable);
|
define_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||||
}
|
}
|
||||||
define_native_property(vm.names.length, length_getter, nullptr, Attribute::Configurable);
|
define_native_property(vm.names.length, length_getter, {}, Attribute::Configurable);
|
||||||
define_native_property(vm.names.name, name_getter, nullptr, Attribute::Configurable);
|
define_native_property(vm.names.name, name_getter, {}, Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptFunction::~ScriptFunction()
|
ScriptFunction::~ScriptFunction()
|
||||||
|
@ -82,7 +82,7 @@ void StringPrototype::initialize(GlobalObject& global_object)
|
|||||||
StringObject::initialize(global_object);
|
StringObject::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
|
|
||||||
define_native_property(vm.names.length, length_getter, nullptr, 0);
|
define_native_property(vm.names.length, length_getter, {}, 0);
|
||||||
define_native_function(vm.names.charAt, char_at, 1, attr);
|
define_native_function(vm.names.charAt, char_at, 1, attr);
|
||||||
define_native_function(vm.names.charCodeAt, char_code_at, 1, attr);
|
define_native_function(vm.names.charCodeAt, char_code_at, 1, attr);
|
||||||
define_native_function(vm.names.repeat, repeat, 1, attr);
|
define_native_function(vm.names.repeat, repeat, 1, attr);
|
||||||
|
@ -47,7 +47,7 @@ void SymbolPrototype::initialize(GlobalObject& global_object)
|
|||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
Object::initialize(global_object);
|
Object::initialize(global_object);
|
||||||
define_native_property(vm.names.description, description_getter, nullptr, Attribute::Configurable);
|
define_native_property(vm.names.description, description_getter, {}, Attribute::Configurable);
|
||||||
define_native_function(vm.names.toString, to_string, 0, Attribute::Writable | Attribute::Configurable);
|
define_native_function(vm.names.toString, to_string, 0, Attribute::Writable | Attribute::Configurable);
|
||||||
define_native_function(vm.names.valueOf, value_of, 0, Attribute::Writable | Attribute::Configurable);
|
define_native_function(vm.names.valueOf, value_of, 0, Attribute::Writable | Attribute::Configurable);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ void TypedArrayPrototype::initialize(GlobalObject& object)
|
|||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
Object::initialize(object);
|
Object::initialize(object);
|
||||||
// FIXME: This should be an accessor property
|
// FIXME: This should be an accessor property
|
||||||
define_native_property(vm.names.length, length_getter, nullptr, Attribute::Configurable);
|
define_native_property(vm.names.length, length_getter, {}, Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedArrayPrototype::~TypedArrayPrototype()
|
TypedArrayPrototype::~TypedArrayPrototype()
|
||||||
|
@ -42,7 +42,7 @@ Uint8ClampedArray::Uint8ClampedArray(u32 length, Object& prototype)
|
|||||||
, m_length(length)
|
, m_length(length)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
define_native_property(vm.names.length, length_getter, nullptr);
|
define_native_property(vm.names.length, length_getter, {});
|
||||||
m_data = (u8*)calloc(m_length, 1);
|
m_data = (u8*)calloc(m_length, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ Function<bool(Editor&)> Editor::find_internal_function(const StringView& name)
|
|||||||
|
|
||||||
ENUMERATE_EDITOR_INTERNAL_FUNCTIONS(__ENUMERATE)
|
ENUMERATE_EDITOR_INTERNAL_FUNCTIONS(__ENUMERATE)
|
||||||
|
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::search_forwards()
|
void Editor::search_forwards()
|
||||||
|
@ -112,13 +112,13 @@ String CodeBlock::render_for_terminal(size_t) const
|
|||||||
OwnPtr<CodeBlock> CodeBlock::parse(Vector<StringView>::ConstIterator& lines)
|
OwnPtr<CodeBlock> CodeBlock::parse(Vector<StringView>::ConstIterator& lines)
|
||||||
{
|
{
|
||||||
if (lines.is_end())
|
if (lines.is_end())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
constexpr auto tick_tick_tick = "```";
|
constexpr auto tick_tick_tick = "```";
|
||||||
|
|
||||||
StringView line = *lines;
|
StringView line = *lines;
|
||||||
if (!line.starts_with(tick_tick_tick))
|
if (!line.starts_with(tick_tick_tick))
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
// Our Markdown extension: we allow
|
// Our Markdown extension: we allow
|
||||||
// specifying a style and a language
|
// specifying a style and a language
|
||||||
@ -134,7 +134,7 @@ OwnPtr<CodeBlock> CodeBlock::parse(Vector<StringView>::ConstIterator& lines)
|
|||||||
StringView style_spec = line.substring_view(3, line.length() - 3);
|
StringView style_spec = line.substring_view(3, line.length() - 3);
|
||||||
auto spec = Text::parse(style_spec);
|
auto spec = Text::parse(style_spec);
|
||||||
if (!spec.has_value())
|
if (!spec.has_value())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
++lines;
|
++lines;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ OwnPtr<Document> Document::parse(const StringView& str)
|
|||||||
|
|
||||||
auto line = Paragraph::Line::parse(lines);
|
auto line = Paragraph::Line::parse(lines);
|
||||||
if (!line)
|
if (!line)
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
paragraph_lines.append(line.release_nonnull());
|
paragraph_lines.append(line.release_nonnull());
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ String Heading::render_for_terminal(size_t) const
|
|||||||
OwnPtr<Heading> Heading::parse(Vector<StringView>::ConstIterator& lines)
|
OwnPtr<Heading> Heading::parse(Vector<StringView>::ConstIterator& lines)
|
||||||
{
|
{
|
||||||
if (lines.is_end())
|
if (lines.is_end())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
const StringView& line = *lines;
|
const StringView& line = *lines;
|
||||||
size_t level;
|
size_t level;
|
||||||
@ -73,12 +73,12 @@ OwnPtr<Heading> Heading::parse(Vector<StringView>::ConstIterator& lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!level || level >= line.length() || line[level] != ' ')
|
if (!level || level >= line.length() || line[level] != ' ')
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
StringView title_view = line.substring_view(level + 1, line.length() - level - 1);
|
StringView title_view = line.substring_view(level + 1, line.length() - level - 1);
|
||||||
auto text = Text::parse(title_view);
|
auto text = Text::parse(title_view);
|
||||||
if (!text.has_value())
|
if (!text.has_value())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
auto heading = make<Heading>(move(text.value()), level);
|
auto heading = make<Heading>(move(text.value()), level);
|
||||||
|
|
||||||
|
@ -47,19 +47,19 @@ String HorizontalRule::render_for_terminal(size_t view_width) const
|
|||||||
OwnPtr<HorizontalRule> HorizontalRule::parse(Vector<StringView>::ConstIterator& lines)
|
OwnPtr<HorizontalRule> HorizontalRule::parse(Vector<StringView>::ConstIterator& lines)
|
||||||
{
|
{
|
||||||
if (lines.is_end())
|
if (lines.is_end())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
const StringView& line = *lines;
|
const StringView& line = *lines;
|
||||||
|
|
||||||
if (line.length() < 3)
|
if (line.length() < 3)
|
||||||
return nullptr;
|
return {};
|
||||||
if (!line.starts_with('-') && !line.starts_with('_') && !line.starts_with('*'))
|
if (!line.starts_with('-') && !line.starts_with('_') && !line.starts_with('*'))
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
auto first_character = line.characters_without_null_termination()[0];
|
auto first_character = line.characters_without_null_termination()[0];
|
||||||
for (auto ch : line) {
|
for (auto ch : line) {
|
||||||
if (ch != first_character)
|
if (ch != first_character)
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
++lines;
|
++lines;
|
||||||
|
@ -122,20 +122,20 @@ OwnPtr<List> List::parse(Vector<StringView>::ConstIterator& lines)
|
|||||||
if (first)
|
if (first)
|
||||||
is_ordered = appears_ordered;
|
is_ordered = appears_ordered;
|
||||||
else if (is_ordered != appears_ordered)
|
else if (is_ordered != appears_ordered)
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
if (!flush_item_if_needed())
|
if (!flush_item_if_needed())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
while (offset + 1 < line.length() && line[offset + 1] == ' ')
|
while (offset + 1 < line.length() && line[offset + 1] == ' ')
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (first)
|
if (first)
|
||||||
return nullptr;
|
return {};
|
||||||
for (size_t i = 0; i < offset; i++) {
|
for (size_t i = 0; i < offset; i++) {
|
||||||
if (line[i] != ' ')
|
if (line[i] != ' ')
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ OwnPtr<List> List::parse(Vector<StringView>::ConstIterator& lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!flush_item_if_needed() || first)
|
if (!flush_item_if_needed() || first)
|
||||||
return nullptr;
|
return {};
|
||||||
return make<List>(move(items), is_ordered);
|
return make<List>(move(items), is_ordered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ String Paragraph::render_for_terminal(size_t) const
|
|||||||
OwnPtr<Paragraph::Line> Paragraph::Line::parse(Vector<StringView>::ConstIterator& lines)
|
OwnPtr<Paragraph::Line> Paragraph::Line::parse(Vector<StringView>::ConstIterator& lines)
|
||||||
{
|
{
|
||||||
if (lines.is_end())
|
if (lines.is_end())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
auto text = Text::parse(*lines++);
|
auto text = Text::parse(*lines++);
|
||||||
if (!text.has_value())
|
if (!text.has_value())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
return make<Paragraph::Line>(text.release_value());
|
return make<Paragraph::Line>(text.release_value());
|
||||||
}
|
}
|
||||||
|
@ -118,12 +118,12 @@ OwnPtr<Table> Table::parse(Vector<StringView>::ConstIterator& lines)
|
|||||||
auto peek_it = lines;
|
auto peek_it = lines;
|
||||||
auto first_line = *peek_it;
|
auto first_line = *peek_it;
|
||||||
if (!first_line.starts_with('|'))
|
if (!first_line.starts_with('|'))
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
++peek_it;
|
++peek_it;
|
||||||
|
|
||||||
if (peek_it.is_end())
|
if (peek_it.is_end())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
auto header_segments = first_line.split_view('|', true);
|
auto header_segments = first_line.split_view('|', true);
|
||||||
auto header_delimiters = peek_it->split_view('|', true);
|
auto header_delimiters = peek_it->split_view('|', true);
|
||||||
@ -141,10 +141,10 @@ OwnPtr<Table> Table::parse(Vector<StringView>::ConstIterator& lines)
|
|||||||
++peek_it;
|
++peek_it;
|
||||||
|
|
||||||
if (header_delimiters.size() != header_segments.size())
|
if (header_delimiters.size() != header_segments.size())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
if (header_delimiters.is_empty())
|
if (header_delimiters.is_empty())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
size_t total_width = 0;
|
size_t total_width = 0;
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ OwnPtr<Table> Table::parse(Vector<StringView>::ConstIterator& lines)
|
|||||||
for (size_t i = 0; i < header_segments.size(); ++i) {
|
for (size_t i = 0; i < header_segments.size(); ++i) {
|
||||||
auto text_option = Text::parse(header_segments[i]);
|
auto text_option = Text::parse(header_segments[i]);
|
||||||
if (!text_option.has_value())
|
if (!text_option.has_value())
|
||||||
return nullptr; // An invalid 'text' in the header should just fail the table parse.
|
return {}; // An invalid 'text' in the header should just fail the table parse.
|
||||||
|
|
||||||
auto text = text_option.release_value();
|
auto text = text_option.release_value();
|
||||||
auto& column = table->m_columns[i];
|
auto& column = table->m_columns[i];
|
||||||
|
@ -138,10 +138,10 @@ int Database::init()
|
|||||||
|
|
||||||
ParseMode mode = ParseMode::UnknownMode;
|
ParseMode mode = ParseMode::UnknownMode;
|
||||||
|
|
||||||
OwnPtr<Vendor> current_vendor = nullptr;
|
OwnPtr<Vendor> current_vendor {};
|
||||||
OwnPtr<Device> current_device = nullptr;
|
OwnPtr<Device> current_device {};
|
||||||
OwnPtr<Class> current_class = nullptr;
|
OwnPtr<Class> current_class {};
|
||||||
OwnPtr<Subclass> current_subclass = nullptr;
|
OwnPtr<Subclass> current_subclass {};
|
||||||
|
|
||||||
auto commit_device = [&]() {
|
auto commit_device = [&]() {
|
||||||
if (current_device && current_vendor) {
|
if (current_device && current_vendor) {
|
||||||
|
@ -69,7 +69,7 @@ int regcomp(regex_t* reg, const char* pattern, int cflags)
|
|||||||
|
|
||||||
// Note that subsequent uses of regcomp() without regfree() _will_ leak memory
|
// Note that subsequent uses of regcomp() without regfree() _will_ leak memory
|
||||||
// This could've been prevented if libc provided a reginit() or similar, but it does not.
|
// This could've been prevented if libc provided a reginit() or similar, but it does not.
|
||||||
reg->__data = new internal_regex_t { 0, 0, nullptr, 0, ReError::REG_NOERR, {}, 0 };
|
reg->__data = new internal_regex_t { 0, 0, {}, 0, ReError::REG_NOERR, {}, 0 };
|
||||||
|
|
||||||
auto preg = impl_from(reg);
|
auto preg = impl_from(reg);
|
||||||
|
|
||||||
|
@ -142,11 +142,11 @@ void CanvasRenderingContext2D::did_draw(const Gfx::FloatRect&)
|
|||||||
OwnPtr<Gfx::Painter> CanvasRenderingContext2D::painter()
|
OwnPtr<Gfx::Painter> CanvasRenderingContext2D::painter()
|
||||||
{
|
{
|
||||||
if (!m_element)
|
if (!m_element)
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
if (!m_element->bitmap()) {
|
if (!m_element->bitmap()) {
|
||||||
if (!m_element->create_bitmap())
|
if (!m_element->create_bitmap())
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return make<Gfx::Painter>(*m_element->bitmap());
|
return make<Gfx::Painter>(*m_element->bitmap());
|
||||||
@ -208,7 +208,7 @@ RefPtr<ImageData> CanvasRenderingContext2D::create_image_data(int width, int hei
|
|||||||
{
|
{
|
||||||
if (!wrapper()) {
|
if (!wrapper()) {
|
||||||
dbgln("Hmm! Attempted to create ImageData for wrapper-less CRC2D.");
|
dbgln("Hmm! Attempted to create ImageData for wrapper-less CRC2D.");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
return ImageData::create_with_size(wrapper()->global_object(), width, height);
|
return ImageData::create_with_size(wrapper()->global_object(), width, height);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ OwnPtr<Messages::ClipboardServer::SetClipboardDataResponse> ClientConnection::ha
|
|||||||
auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.shbuf_id());
|
auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.shbuf_id());
|
||||||
if (!shared_buffer) {
|
if (!shared_buffer) {
|
||||||
did_misbehave("SetClipboardData: Bad shared buffer ID");
|
did_misbehave("SetClipboardData: Bad shared buffer ID");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
Storage::the().set_data(*shared_buffer, message.data_size(), message.mime_type(), message.metadata().entries());
|
Storage::the().set_data(*shared_buffer, message.data_size(), message.mime_type(), message.metadata().entries());
|
||||||
return make<Messages::ClipboardServer::SetClipboardDataResponse>();
|
return make<Messages::ClipboardServer::SetClipboardDataResponse>();
|
||||||
|
@ -65,14 +65,14 @@ OwnPtr<Messages::ImageDecoderServer::DecodeImageResponse> ClientConnection::hand
|
|||||||
#ifdef IMAGE_DECODER_DEBUG
|
#ifdef IMAGE_DECODER_DEBUG
|
||||||
dbgln("Could not map encoded data buffer");
|
dbgln("Could not map encoded data buffer");
|
||||||
#endif
|
#endif
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.encoded_size() > (size_t)encoded_buffer->size()) {
|
if (message.encoded_size() > (size_t)encoded_buffer->size()) {
|
||||||
#ifdef IMAGE_DECODER_DEBUG
|
#ifdef IMAGE_DECODER_DEBUG
|
||||||
dbgln("Encoded buffer is smaller than encoded size");
|
dbgln("Encoded buffer is smaller than encoded size");
|
||||||
#endif
|
#endif
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IMAGE_DECODER_DEBUG
|
#ifdef IMAGE_DECODER_DEBUG
|
||||||
|
@ -67,7 +67,7 @@ OwnPtr<Messages::LaunchServer::OpenURLResponse> ClientConnection::handle(const M
|
|||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
// You are not on the list, go home!
|
// You are not on the list, go home!
|
||||||
did_misbehave(String::formatted("Client requested a combination of handler/URL that was not on the list: '{}' with '{}'", request.handler_name(), request.url()).characters());
|
did_misbehave(String::formatted("Client requested a combination of handler/URL that was not on the list: '{}' with '{}'", request.handler_name(), request.url()).characters());
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,12 +94,12 @@ OwnPtr<Messages::LaunchServer::AddAllowedURLResponse> ClientConnection::handle(c
|
|||||||
{
|
{
|
||||||
if (m_allowlist_is_sealed) {
|
if (m_allowlist_is_sealed) {
|
||||||
did_misbehave("Got request to add more allowed handlers after list was sealed");
|
did_misbehave("Got request to add more allowed handlers after list was sealed");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!request.url().is_valid()) {
|
if (!request.url().is_valid()) {
|
||||||
did_misbehave("Got request to allow invalid URL");
|
did_misbehave("Got request to allow invalid URL");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
m_allowlist.empend(String(), false, Vector<URL> { request.url() });
|
m_allowlist.empend(String(), false, Vector<URL> { request.url() });
|
||||||
@ -111,12 +111,12 @@ OwnPtr<Messages::LaunchServer::AddAllowedHandlerWithAnyURLResponse> ClientConnec
|
|||||||
{
|
{
|
||||||
if (m_allowlist_is_sealed) {
|
if (m_allowlist_is_sealed) {
|
||||||
did_misbehave("Got request to add more allowed handlers after list was sealed");
|
did_misbehave("Got request to add more allowed handlers after list was sealed");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.handler_name().is_empty()) {
|
if (request.handler_name().is_empty()) {
|
||||||
did_misbehave("Got request to allow empty handler name");
|
did_misbehave("Got request to allow empty handler name");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
m_allowlist.empend(request.handler_name(), true, Vector<URL>());
|
m_allowlist.empend(request.handler_name(), true, Vector<URL>());
|
||||||
@ -128,17 +128,17 @@ OwnPtr<Messages::LaunchServer::AddAllowedHandlerWithOnlySpecificURLsResponse> Cl
|
|||||||
{
|
{
|
||||||
if (m_allowlist_is_sealed) {
|
if (m_allowlist_is_sealed) {
|
||||||
did_misbehave("Got request to add more allowed handlers after list was sealed");
|
did_misbehave("Got request to add more allowed handlers after list was sealed");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.handler_name().is_empty()) {
|
if (request.handler_name().is_empty()) {
|
||||||
did_misbehave("Got request to allow empty handler name");
|
did_misbehave("Got request to allow empty handler name");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.urls().is_empty()) {
|
if (request.urls().is_empty()) {
|
||||||
did_misbehave("Got request to allow empty URL list");
|
did_misbehave("Got request to allow empty URL list");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
m_allowlist.empend(request.handler_name(), false, request.urls());
|
m_allowlist.empend(request.handler_name(), false, request.urls());
|
||||||
@ -150,7 +150,7 @@ OwnPtr<Messages::LaunchServer::SealAllowlistResponse> ClientConnection::handle(c
|
|||||||
{
|
{
|
||||||
if (m_allowlist_is_sealed) {
|
if (m_allowlist_is_sealed) {
|
||||||
did_misbehave("Got more than one request to seal the allowed handlers list");
|
did_misbehave("Got more than one request to seal the allowed handlers list");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return make<Messages::LaunchServer::SealAllowlistResponse>();
|
return make<Messages::LaunchServer::SealAllowlistResponse>();
|
||||||
|
@ -48,7 +48,7 @@ OwnPtr<Download> GeminiProtocol::start_download(ClientConnection& client, const
|
|||||||
|
|
||||||
auto pipe_result = get_pipe_for_download();
|
auto pipe_result = get_pipe_for_download();
|
||||||
if (pipe_result.is_error())
|
if (pipe_result.is_error())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
auto output_stream = make<OutputFileStream>(pipe_result.value().write_fd);
|
auto output_stream = make<OutputFileStream>(pipe_result.value().write_fd);
|
||||||
output_stream->make_unbuffered();
|
output_stream->make_unbuffered();
|
||||||
|
@ -53,7 +53,7 @@ OwnPtr<Download> HttpProtocol::start_download(ClientConnection& client, const St
|
|||||||
|
|
||||||
auto pipe_result = get_pipe_for_download();
|
auto pipe_result = get_pipe_for_download();
|
||||||
if (pipe_result.is_error())
|
if (pipe_result.is_error())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
auto output_stream = make<OutputFileStream>(pipe_result.value().write_fd);
|
auto output_stream = make<OutputFileStream>(pipe_result.value().write_fd);
|
||||||
output_stream->make_unbuffered();
|
output_stream->make_unbuffered();
|
||||||
|
@ -53,7 +53,7 @@ OwnPtr<Download> HttpsProtocol::start_download(ClientConnection& client, const S
|
|||||||
|
|
||||||
auto pipe_result = get_pipe_for_download();
|
auto pipe_result = get_pipe_for_download();
|
||||||
if (pipe_result.is_error())
|
if (pipe_result.is_error())
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
auto output_stream = make<OutputFileStream>(pipe_result.value().write_fd);
|
auto output_stream = make<OutputFileStream>(pipe_result.value().write_fd);
|
||||||
output_stream->make_unbuffered();
|
output_stream->make_unbuffered();
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user