Skip to content

Commit

Permalink
Everywhere: Re-format with clang-format-11
Browse files Browse the repository at this point in the history
Compared to version 10 this fixes a bunch of formatting issues, mostly
around structs/classes with attributes like [[gnu::packed]], and
incorrect insertion of spaces in parameter types ("T &"/"T &&").
I also removed a bunch of // clang-format off/on and FIXME comments that
are no longer relevant - on the other hand it tried to destroy a couple of
neatly formatted comments, so I had to add some as well.
  • Loading branch information
linusg authored and awesomekling committed Dec 31, 2020
1 parent 2568a93 commit bbe787a
Show file tree
Hide file tree
Showing 54 changed files with 130 additions and 230 deletions.
6 changes: 2 additions & 4 deletions AK/Endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ template<typename T>
OutputStream& operator<<(OutputStream&, LittleEndian<T>);

template<typename T>
class [[gnu::packed]] LittleEndian
{
class [[gnu::packed]] LittleEndian {
public:
friend InputStream& operator>><T>(InputStream&, LittleEndian<T>&);
friend OutputStream& operator<<<T>(OutputStream&, LittleEndian<T>);
Expand Down Expand Up @@ -134,8 +133,7 @@ template<typename T>
OutputStream& operator<<(OutputStream&, BigEndian<T>);

template<typename T>
class [[gnu::packed]] BigEndian
{
class [[gnu::packed]] BigEndian {
public:
friend InputStream& operator>><T>(InputStream&, BigEndian<T>&);
friend OutputStream& operator<<<T>(OutputStream&, BigEndian<T>);
Expand Down
3 changes: 1 addition & 2 deletions AK/IPv4Address.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@

namespace AK {

class [[gnu::packed]] IPv4Address
{
class [[gnu::packed]] IPv4Address {
enum class SubnetClass : int {
A = 0,
B,
Expand Down
3 changes: 1 addition & 2 deletions AK/MACAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
#include <AK/String.h>
#include <AK/Types.h>

class [[gnu::packed]] MACAddress
{
class [[gnu::packed]] MACAddress {
static constexpr size_t s_mac_address_length = 6u;

public:
Expand Down
9 changes: 4 additions & 5 deletions AK/Optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
namespace AK {

template<typename T>
class alignas(T) [[nodiscard]] Optional
{
class alignas(T) [[nodiscard]] Optional {
public:
Optional() { }

Expand All @@ -53,13 +52,13 @@ class alignas(T) [[nodiscard]] Optional
new (&m_storage) T(value);
}

Optional(T && value)
Optional(T&& value)
: m_has_value(true)
{
new (&m_storage) T(move(value));
}

Optional(Optional && other)
Optional(Optional&& other)
: m_has_value(other.m_has_value)
{
if (other.has_value()) {
Expand Down Expand Up @@ -119,7 +118,7 @@ class alignas(T) [[nodiscard]] Optional
}

template<typename... Parameters>
ALWAYS_INLINE void emplace(Parameters && ... parameters)
ALWAYS_INLINE void emplace(Parameters&&... parameters)
{
clear();
m_has_value = true;
Expand Down
13 changes: 3 additions & 10 deletions AK/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,21 @@
namespace AK {

template<typename ValueType, typename ErrorType>
class [[nodiscard]] Result
{
class [[nodiscard]] Result {
public:
Result(const ValueType& res)
: m_result(res)
{
}
Result(ValueType && res)
Result(ValueType&& res)
: m_result(move(res))
{
}
Result(const ErrorType& error)
: m_error(error)
{
}
Result(ErrorType && error)
Result(ErrorType&& error)
: m_error(move(error))
{
}
Expand All @@ -58,19 +57,13 @@ class [[nodiscard]] Result
{
}

// FIXME: clang-format gets confused about Result. Why?
// clang-format off
Result(Result&& other)
// clang-format on
: m_result(move(other.m_result))
, m_error(move(other.m_error))
{
}

// FIXME: clang-format gets confused about Result. Why?
// clang-format off
Result(Result& other)
// clang-format on
: m_result(other.m_result)
, m_error(other.m_error)
{
Expand Down
54 changes: 18 additions & 36 deletions Kernel/ACPI/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ enum class IA_PC_Flags : u8 {
CMOS_RTC_Not_Present = 1 << 5
};

struct [[gnu::packed]] HardwareFeatures
{
struct [[gnu::packed]] HardwareFeatures {
bool wbinvd : 1;
bool wbinvd_flush : 1;
bool processor_c1 : 1;
Expand All @@ -95,8 +94,7 @@ struct [[gnu::packed]] HardwareFeatures
bool hardware_reduced_acpi : 1;
bool low_power_s0_idle_capable : 1;
};
struct [[gnu::packed]] x86_Specific_Flags
{
struct [[gnu::packed]] x86_Specific_Flags {
bool legacy_devices : 1;
bool keyboard_8042 : 1;
bool vga_not_present : 1;
Expand Down Expand Up @@ -132,26 +130,23 @@ enum class BitWidth {
}

namespace Structures {
struct [[gnu::packed]] RSDPDescriptor
{
struct [[gnu::packed]] RSDPDescriptor {
char sig[8];
u8 checksum;
char oem_id[6];
u8 revision;
u32 rsdt_ptr;
};

struct [[gnu::packed]] RSDPDescriptor20
{
struct [[gnu::packed]] RSDPDescriptor20 {
RSDPDescriptor base;
u32 length;
u64 xsdt_ptr;
u8 ext_checksum;
u8 reserved[3];
};

struct [[gnu::packed]] SDTHeader
{
struct [[gnu::packed]] SDTHeader {
char sig[4];
u32 length;
u8 revision;
Expand All @@ -163,29 +158,25 @@ struct [[gnu::packed]] SDTHeader
u32 creator_revision;
};

struct [[gnu::packed]] RSDT
{
struct [[gnu::packed]] RSDT {
SDTHeader h;
u32 table_ptrs[];
};

struct [[gnu::packed]] XSDT
{
struct [[gnu::packed]] XSDT {
SDTHeader h;
u64 table_ptrs[];
};

struct [[gnu::packed]] GenericAddressStructure
{
struct [[gnu::packed]] GenericAddressStructure {
u8 address_space;
u8 bit_width;
u8 bit_offset;
u8 access_size;
u64 address;
};

struct [[gnu::packed]] HPET
{
struct [[gnu::packed]] HPET {
SDTHeader h;
u8 hardware_revision_id;
u8 attributes;
Expand All @@ -196,8 +187,7 @@ struct [[gnu::packed]] HPET
u8 page_protection;
};

struct [[gnu::packed]] FADT
{
struct [[gnu::packed]] FADT {
SDTHeader h;
u32 firmware_ctrl;
u32 dsdt_ptr;
Expand Down Expand Up @@ -274,32 +264,28 @@ enum class MADTEntryType {
GIC_Interrupt_Translation = 0xF
};

struct [[gnu::packed]] MADTEntryHeader
{
struct [[gnu::packed]] MADTEntryHeader {
u8 type;
u8 length;
};

namespace MADTEntries {
struct [[gnu::packed]] IOAPIC
{
struct [[gnu::packed]] IOAPIC {
MADTEntryHeader h;
u8 ioapic_id;
u8 reserved;
u32 ioapic_address;
u32 gsi_base;
};

struct [[gnu::packed]] ProcessorLocalAPIC
{
struct [[gnu::packed]] ProcessorLocalAPIC {
MADTEntryHeader h;
u8 acpi_processor_id;
u8 apic_id;
u32 flags;
};

struct [[gnu::packed]] InterruptSourceOverride
{
struct [[gnu::packed]] InterruptSourceOverride {
MADTEntryHeader h;
u8 bus;
u8 source;
Expand All @@ -308,31 +294,27 @@ struct [[gnu::packed]] InterruptSourceOverride
};
}

struct [[gnu::packed]] MADT
{
struct [[gnu::packed]] MADT {
SDTHeader h;
u32 lapic_address;
u32 flags;
MADTEntryHeader entries[];
};

struct [[gnu::packed]] AMLTable
{
struct [[gnu::packed]] AMLTable {
SDTHeader h;
char aml_code[];
};

struct [[gnu::packed]] PCI_MMIO_Descriptor
{
struct [[gnu::packed]] PCI_MMIO_Descriptor {
u64 base_addr;
u16 seg_group_number;
u8 start_pci_bus;
u8 end_pci_bus;
u32 reserved;
};

struct [[gnu::packed]] MCFG
{
struct [[gnu::packed]] MCFG {
SDTHeader header;
u64 reserved;
PCI_MMIO_Descriptor descriptors[];
Expand Down
36 changes: 12 additions & 24 deletions Kernel/ACPI/MultiProcessorParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
namespace Kernel {
namespace MultiProcessor {

struct [[gnu::packed]] FloatingPointer
{
struct [[gnu::packed]] FloatingPointer {
char sig[4];
u32 physical_address_ptr;
u8 length;
Expand All @@ -44,13 +43,11 @@ struct [[gnu::packed]] FloatingPointer
u8 feature_info[5];
};

struct [[gnu::packed]] EntryHeader
{
struct [[gnu::packed]] EntryHeader {
u8 entry_type;
};

struct [[gnu::packed]] ConfigurationTableHeader
{
struct [[gnu::packed]] ConfigurationTableHeader {
char sig[4];
u16 length;
u8 specification_revision;
Expand Down Expand Up @@ -78,14 +75,12 @@ enum class ConfigurationTableEntryType {
CompatibilityBusAddressSpaceModifier = 130
};

struct [[gnu::packed]] ExtEntryHeader
{
struct [[gnu::packed]] ExtEntryHeader {
u8 entry_type;
u8 entry_length;
};

struct [[gnu::packed]] ProcessorEntry
{
struct [[gnu::packed]] ProcessorEntry {
EntryHeader h;
u8 local_apic_id;
u8 local_apic_version;
Expand All @@ -95,15 +90,13 @@ struct [[gnu::packed]] ProcessorEntry
u8 reserved[8];
};

struct [[gnu::packed]] BusEntry
{
struct [[gnu::packed]] BusEntry {
EntryHeader h;
u8 bus_id;
char bus_type[6];
};

struct [[gnu::packed]] IOAPICEntry
{
struct [[gnu::packed]] IOAPICEntry {
EntryHeader h;
u8 ioapic_id;
u8 ioapic_version;
Expand All @@ -118,8 +111,7 @@ enum class InterruptType {
ExtINT = 3,
};

struct [[gnu::packed]] IOInterruptAssignmentEntry
{
struct [[gnu::packed]] IOInterruptAssignmentEntry {
EntryHeader h;
u8 interrupt_type;
u8 polarity;
Expand All @@ -130,8 +122,7 @@ struct [[gnu::packed]] IOInterruptAssignmentEntry
u8 destination_ioapic_intin_pin;
};

struct [[gnu::packed]] LocalInterruptAssignmentEntry
{
struct [[gnu::packed]] LocalInterruptAssignmentEntry {
EntryHeader h;
u8 interrupt_type;
u8 polarity;
Expand All @@ -148,26 +139,23 @@ enum class SystemAddressType {
Prefetch = 2,
};

struct [[gnu::packed]] SystemAddressSpaceMappingEntry
{
struct [[gnu::packed]] SystemAddressSpaceMappingEntry {
ExtEntryHeader h;
u8 bus_id;
u8 address_type;
u64 address_base;
u64 length;
};

struct [[gnu::packed]] BusHierarchyDescriptorEntry
{
struct [[gnu::packed]] BusHierarchyDescriptorEntry {
ExtEntryHeader h;
u8 bus_id;
u8 bus_info;
u8 parent_bus;
u8 reserved[3];
};

struct [[gnu::packed]] CompatibilityBusAddressSpaceModifierEntry
{
struct [[gnu::packed]] CompatibilityBusAddressSpaceModifierEntry {
ExtEntryHeader h;
u8 bus_id;
u8 address_modifier;
Expand Down
Loading

0 comments on commit bbe787a

Please sign in to comment.