All: Clear lines with only whitspace in them

This commit is contained in:
Bananymous 2023-09-09 22:52:03 +03:00
parent d77f455065
commit 720bc418a6
67 changed files with 95 additions and 119 deletions

View File

@ -119,7 +119,7 @@ namespace BAN
m_size -= count; m_size -= count;
m_data[m_size] = '\0'; m_data[m_size] = '\0';
} }
void String::clear() void String::clear()
{ {
m_size = 0; m_size = 0;

View File

@ -171,7 +171,7 @@ namespace BAN
{ {
return m_size; return m_size;
} }
const char* StringView::data() const const char* StringView::data() const
{ {
return m_data; return m_data;

View File

@ -24,7 +24,7 @@ namespace BAN
leap_years++; leap_years++;
return leap_years; return leap_years;
} }
static constexpr uint64_t month_days[] { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; static constexpr uint64_t month_days[] { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
uint64_t to_unix_time(const BAN::Time& time) uint64_t to_unix_time(const BAN::Time& time)

View File

@ -28,9 +28,8 @@ namespace BAN::Formatter
static size_t parse_format_and_print_argument(F putc, const char* format, T&& arg); static size_t parse_format_and_print_argument(F putc, const char* format, T&& arg);
} }
/* /*
IMPLEMENTATION IMPLEMENTATION
*/ */
@ -42,7 +41,7 @@ namespace BAN::Formatter
int fill = 0; int fill = 0;
bool upper = false; bool upper = false;
}; };
template<typename F> template<typename F>
void print(F putc, const char* format) void print(F putc, const char* format)
{ {
@ -232,7 +231,7 @@ namespace BAN::Formatter
} }
/* /*
TEMPLATE SPECIALIZATIONS TEMPLATE SPECIALIZATIONS
*/ */
@ -245,5 +244,5 @@ namespace BAN::Formatter
template<typename F> void print_argument(F putc, bool value, const ValueFormat&) { print(putc, value ? "true" : "false"); } template<typename F> void print_argument(F putc, bool value, const ValueFormat&) { print(putc, value ? "true" : "false"); }
template<typename F> void print_argument(F putc, const char* value, const ValueFormat&) { print(putc, value); } template<typename F> void print_argument(F putc, const char* value, const ValueFormat&) { print(putc, value); }
template<typename F> void print_argument(F putc, char* value, const ValueFormat&) { print(putc, value); } template<typename F> void print_argument(F putc, char* value, const ValueFormat&) { print(putc, value); }
} }

View File

@ -5,7 +5,7 @@
namespace BAN namespace BAN
{ {
template<typename, size_t> class Array; template<typename, size_t> class Array;
template<typename> class ErrorOr; template<typename> class ErrorOr;
template<typename> class Function; template<typename> class Function;

View File

@ -85,8 +85,6 @@ namespace BAN
friend class HashSet<T, HASH>; friend class HashSet<T, HASH>;
}; };
template<typename T, typename HASH> template<typename T, typename HASH>
HashSet<T, HASH>::HashSet(const HashSet<T, HASH>& other) HashSet<T, HASH>::HashSet(const HashSet<T, HASH>& other)
: m_buckets(other.m_buckets) : m_buckets(other.m_buckets)
@ -231,8 +229,6 @@ namespace BAN
return m_buckets[index]; return m_buckets[index];
} }
template<typename T, typename HASH> template<typename T, typename HASH>
HashSetIterator<T, HASH>& HashSetIterator<T, HASH>::operator++() HashSetIterator<T, HASH>& HashSetIterator<T, HASH>::operator++()
{ {

View File

@ -9,7 +9,7 @@ namespace BAN
template<typename T, bool CONST> template<typename T, bool CONST>
class LinkedListIterator; class LinkedListIterator;
template<typename T> template<typename T>
class LinkedList class LinkedList
{ {
@ -114,8 +114,6 @@ namespace BAN
friend class LinkedListIterator<T, !CONST>; friend class LinkedListIterator<T, !CONST>;
}; };
template<typename T> template<typename T>
LinkedList<T>& LinkedList<T>::operator=(const LinkedList<T>& other) LinkedList<T>& LinkedList<T>::operator=(const LinkedList<T>& other)
{ {
@ -293,8 +291,6 @@ namespace BAN
return node; return node;
} }
template<typename T, bool CONST> template<typename T, bool CONST>
template<bool C> template<bool C>
LinkedListIterator<T, CONST>::LinkedListIterator(const LinkedListIterator<T, C>& other, enable_if_t<C == CONST || !C>*) LinkedListIterator<T, CONST>::LinkedListIterator(const LinkedListIterator<T, C>& other, enable_if_t<C == CONST || !C>*)
@ -379,7 +375,7 @@ namespace BAN
ASSERT(m_current); ASSERT(m_current);
return &m_current->value; return &m_current->value;
} }
template<typename T, bool CONST> template<typename T, bool CONST>
bool LinkedListIterator<T, CONST>::operator==(const LinkedListIterator<T, CONST>& other) const bool LinkedListIterator<T, CONST>::operator==(const LinkedListIterator<T, CONST>& other) const
{ {

View File

@ -132,7 +132,7 @@ namespace BAN
ASSERT(has_value()); ASSERT(has_value());
return value(); return value();
} }
template<typename T> template<typename T>
const T& Optional<T>::operator*() const const T& Optional<T>::operator*() const
{ {
@ -160,7 +160,7 @@ namespace BAN
ASSERT(has_value()); ASSERT(has_value());
return (const T&)m_storage; return (const T&)m_storage;
} }
template<typename T> template<typename T>
T& Optional<T>::value() T& Optional<T>::value()
{ {

View File

@ -2,7 +2,7 @@
namespace BAN namespace BAN
{ {
template<typename T> struct remove_refenrece { using type = T; }; template<typename T> struct remove_refenrece { using type = T; };
template<typename T> struct remove_refenrece<T&> { using type = T; }; template<typename T> struct remove_refenrece<T&> { using type = T; };
template<typename T> struct remove_refenrece<T&&> { using type = T; }; template<typename T> struct remove_refenrece<T&&> { using type = T; };
@ -68,7 +68,7 @@ namespace BAN
template<typename T> struct is_const : false_type {}; template<typename T> struct is_const : false_type {};
template<typename T> struct is_const<const T> : true_type {}; template<typename T> struct is_const<const T> : true_type {};
template<typename T> inline constexpr bool is_const_v = is_const<T>::value; template<typename T> inline constexpr bool is_const_v = is_const<T>::value;
template<typename T> struct is_arithmetic { static constexpr bool value = is_integral_v<T> || is_floating_point_v<T>; }; template<typename T> struct is_arithmetic { static constexpr bool value = is_integral_v<T> || is_floating_point_v<T>; };
template<typename T> inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value; template<typename T> inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;

View File

@ -253,7 +253,7 @@ namespace BAN
return true; return true;
return false; return false;
} }
template<typename T> template<typename T>
const T& Vector<T>::operator[](size_type index) const const T& Vector<T>::operator[](size_type index) const
{ {

View File

@ -158,7 +158,7 @@ namespace LibELF
bool ELF::is_x86_64() const { return m_data[EI_CLASS] == ELFCLASS64; } bool ELF::is_x86_64() const { return m_data[EI_CLASS] == ELFCLASS64; }
/* /*
64 bit ELF 64 bit ELF
*/ */
@ -280,9 +280,8 @@ namespace LibELF
return *(const Elf64SectionHeader*)(m_data.data() + file_header.e_shoff + file_header.e_shentsize * index); return *(const Elf64SectionHeader*)(m_data.data() + file_header.e_shoff + file_header.e_shentsize * index);
} }
/* /*
32 bit ELF 32 bit ELF
*/ */
@ -404,5 +403,4 @@ namespace LibELF
return *(const Elf32SectionHeader*)(m_data.data() + file_header.e_shoff + file_header.e_shentsize * index); return *(const Elf32SectionHeader*)(m_data.data() + file_header.e_shoff + file_header.e_shentsize * index);
} }
} }

View File

@ -78,7 +78,6 @@ namespace LibELF
Elf32Word p_align; Elf32Word p_align;
}; };
using Elf64Addr = uint64_t; using Elf64Addr = uint64_t;
using Elf64Off = uint64_t; using Elf64Off = uint64_t;
using Elf64Half = uint16_t; using Elf64Half = uint16_t;

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
BOCHS_CONFIG_FILE=bochsrc BOCHS_CONFIG_FILE=bochsrc
COM1_TERMINAL=kitty COM1_TERMINAL=kitty
COM1_DEVICE_FILE=com1-term-device COM1_DEVICE_FILE=com1-term-device

View File

@ -154,7 +154,7 @@ found:
"popa;" "popa;"
"iret;" "iret;"
); );
extern "C" void syscall_asm(); extern "C" void syscall_asm();
asm( asm(
".global syscall_asm;" ".global syscall_asm;"

View File

@ -207,7 +207,6 @@ namespace Kernel
unmap_page(page); unmap_page(page);
} }
uint8_t MMU::get_page_flags(vaddr_t address) const uint8_t MMU::get_page_flags(vaddr_t address) const
{ {
uint32_t pdpte = (address & 0xC0000000) >> 30; uint32_t pdpte = (address & 0xC0000000) >> 30;

View File

@ -16,7 +16,7 @@ extern uint8_t g_userspace_end[];
namespace Kernel namespace Kernel
{ {
static PageTable* s_kernel = nullptr; static PageTable* s_kernel = nullptr;
static PageTable* s_current = nullptr; static PageTable* s_current = nullptr;
static bool s_has_nxe = false; static bool s_has_nxe = false;

View File

@ -35,7 +35,7 @@
.skip 16384 .skip 16384
.global g_boot_stack_top .global g_boot_stack_top
g_boot_stack_top: g_boot_stack_top:
.global g_kernel_cmdline .global g_kernel_cmdline
g_kernel_cmdline: g_kernel_cmdline:
.skip 4096 .skip 4096

View File

@ -104,7 +104,7 @@ void __cxa_finalize(void *f)
**/ **/
(*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr);
__atexit_funcs[i].destructor_func = 0; __atexit_funcs[i].destructor_func = 0;
/* /*
* Notice that we didn't decrement __atexit_func_count: this is because this algorithm * Notice that we didn't decrement __atexit_func_count: this is because this algorithm
* requires patching to deal with the FIXME outlined above. * requires patching to deal with the FIXME outlined above.
@ -113,8 +113,6 @@ void __cxa_finalize(void *f)
}; };
}; };
namespace __cxxabiv1 namespace __cxxabiv1
{ {
/* guard variables */ /* guard variables */
@ -122,19 +120,19 @@ namespace __cxxabiv1
/* The ABI requires a 64-bit type. */ /* The ABI requires a 64-bit type. */
__extension__ typedef int __guard __attribute__((mode(__DI__))); __extension__ typedef int __guard __attribute__((mode(__DI__)));
int __cxa_guard_acquire (__guard* g) int __cxa_guard_acquire (__guard* g)
{ {
Kernel::LockGuard lock_guard(s_spin_lock); Kernel::LockGuard lock_guard(s_spin_lock);
return !*(int*)g; return !*(int*)g;
} }
void __cxa_guard_release (__guard* g) void __cxa_guard_release (__guard* g)
{ {
Kernel::LockGuard lock_guard(s_spin_lock); Kernel::LockGuard lock_guard(s_spin_lock);
*(int*)g = 1; *(int*)g = 1;
} }
void __cxa_guard_abort (__guard*) void __cxa_guard_abort (__guard*)
{ {
Kernel::panic("__cxa_guard_abort"); Kernel::panic("__cxa_guard_abort");

View File

@ -11,7 +11,7 @@ namespace Kernel::API
struct dirent dirent; struct dirent dirent;
DirectoryEntry* next() const { return (DirectoryEntry*)((uintptr_t)this + rec_len); } DirectoryEntry* next() const { return (DirectoryEntry*)((uintptr_t)this + rec_len); }
}; };
struct DirectoryEntryList struct DirectoryEntryList
{ {
size_t entry_count { 0 }; size_t entry_count { 0 };

View File

@ -73,7 +73,7 @@ namespace CPUID
const char* feature_string_ecx(uint32_t feat); const char* feature_string_ecx(uint32_t feat);
const char* feature_string_edx(uint32_t feat); const char* feature_string_edx(uint32_t feat);
const char* get_vendor(); const char* get_vendor();
void get_features(uint32_t& ecx, uint32_t& edx); void get_features(uint32_t& ecx, uint32_t& edx);
bool is_64_bit(); bool is_64_bit();

View File

@ -11,7 +11,7 @@ namespace Kernel
{ {
BAN_NON_COPYABLE(CriticalScope); BAN_NON_COPYABLE(CriticalScope);
BAN_NON_MOVABLE(CriticalScope); BAN_NON_MOVABLE(CriticalScope);
public: public:
CriticalScope() CriticalScope()
{ {

View File

@ -18,7 +18,7 @@ namespace Kernel
virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override { return 0; } virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override { return 0; }
virtual BAN::ErrorOr<size_t> write_impl(off_t, const void*, size_t size) override { return size; }; virtual BAN::ErrorOr<size_t> write_impl(off_t, const void*, size_t size) override { return size; };
private: private:
const dev_t m_rdev; const dev_t m_rdev;
}; };

View File

@ -18,7 +18,7 @@ namespace Kernel
virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override; virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override;
virtual BAN::ErrorOr<size_t> write_impl(off_t, const void*, size_t size) override { return size; }; virtual BAN::ErrorOr<size_t> write_impl(off_t, const void*, size_t size) override { return size; };
private: private:
const dev_t m_rdev; const dev_t m_rdev;
}; };

View File

@ -5,7 +5,7 @@
namespace Kernel namespace Kernel
{ {
class DevFileSystem final : public RamFileSystem class DevFileSystem final : public RamFileSystem
{ {
public: public:
@ -13,7 +13,7 @@ namespace Kernel
static DevFileSystem& get(); static DevFileSystem& get();
void initialize_device_updater(); void initialize_device_updater();
void add_device(BAN::StringView path, BAN::RefPtr<RamInode>); void add_device(BAN::StringView path, BAN::RefPtr<RamInode>);
dev_t get_next_dev(); dev_t get_next_dev();

View File

@ -4,7 +4,7 @@
namespace Kernel namespace Kernel
{ {
class FileSystem class FileSystem
{ {
public: public:

View File

@ -6,7 +6,7 @@
namespace Kernel namespace Kernel
{ {
class RamInode; class RamInode;
class RamDirectoryInode; class RamDirectoryInode;

View File

@ -14,7 +14,7 @@ namespace Kernel
public: public:
static BAN::ErrorOr<BAN::RefPtr<RamInode>> create(RamFileSystem&, mode_t, uid_t, gid_t); static BAN::ErrorOr<BAN::RefPtr<RamInode>> create(RamFileSystem&, mode_t, uid_t, gid_t);
virtual ~RamInode() = default; virtual ~RamInode() = default;
virtual ino_t ino() const override { return m_inode_info.ino; } virtual ino_t ino() const override { return m_inode_info.ino; }
virtual Mode mode() const override { return { m_inode_info.mode }; } virtual Mode mode() const override { return { m_inode_info.mode }; }
virtual nlink_t nlink() const override { return m_inode_info.nlink; } virtual nlink_t nlink() const override { return m_inode_info.nlink; }
@ -80,7 +80,7 @@ namespace Kernel
private: private:
RamDirectoryInode(RamFileSystem&, ino_t parent, mode_t, uid_t, gid_t); RamDirectoryInode(RamFileSystem&, ino_t parent, mode_t, uid_t, gid_t);
private: private:
static constexpr size_t m_name_max = NAME_MAX; static constexpr size_t m_name_max = NAME_MAX;
struct Entry struct Entry
@ -106,7 +106,7 @@ namespace Kernel
virtual off_t size() const override { return m_target.size(); } virtual off_t size() const override { return m_target.size(); }
BAN::ErrorOr<void> set_link_target(BAN::StringView); BAN::ErrorOr<void> set_link_target(BAN::StringView);
protected: protected:
virtual BAN::ErrorOr<BAN::String> link_target_impl() override; virtual BAN::ErrorOr<BAN::String> link_target_impl() override;
@ -115,7 +115,7 @@ namespace Kernel
private: private:
BAN::String m_target; BAN::String m_target;
friend class RamFileSystem; friend class RamFileSystem;
}; };

View File

@ -22,7 +22,7 @@ namespace Kernel
{ {
m_lock.unlock(); m_lock.unlock();
} }
private: private:
Lock& m_lock; Lock& m_lock;
}; };

View File

@ -8,7 +8,7 @@
namespace Kernel namespace Kernel
{ {
class Heap class Heap
{ {
BAN_NON_COPYABLE(Heap); BAN_NON_COPYABLE(Heap);

View File

@ -18,5 +18,5 @@ namespace Kernel
using vaddr_t = uintptr_t; using vaddr_t = uintptr_t;
using paddr_t = uintptr_t; using paddr_t = uintptr_t;
} }

View File

@ -30,7 +30,7 @@ namespace Kernel
virtual dev_t rdev() const override { return m_rdev; } virtual dev_t rdev() const override { return m_rdev; }
virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) { return BAN::Error::from_errno(ENOTSUP); } virtual BAN::ErrorOr<size_t> read(size_t, void*, size_t) { return BAN::Error::from_errno(ENOTSUP); }
private: private:
const dev_t m_rdev; const dev_t m_rdev;
}; };

View File

@ -52,7 +52,7 @@ namespace Kernel
protected: protected:
virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override; virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override;
private: private:
const dev_t m_rdev; const dev_t m_rdev;
}; };

View File

@ -42,7 +42,7 @@ namespace Kernel
virtual uint32_t width() const override; virtual uint32_t width() const override;
virtual uint32_t height() const override; virtual uint32_t height() const override;
virtual void putchar(uint8_t) override; virtual void putchar(uint8_t) override;
virtual void update() override; virtual void update() override;
protected: protected:
@ -55,7 +55,7 @@ namespace Kernel
private: private:
BAN::String m_name; BAN::String m_name;
Serial m_serial; Serial m_serial;
public: public:
virtual dev_t rdev() const override { return m_rdev; } virtual dev_t rdev() const override { return m_rdev; }
private: private:

View File

@ -11,7 +11,7 @@
namespace Kernel namespace Kernel
{ {
class VirtualTTY : public TTY class VirtualTTY : public TTY
{ {
public: public:

View File

@ -8,5 +8,5 @@ namespace Kernel
bool canonical { true }; bool canonical { true };
bool echo { true }; bool echo { true };
}; };
} }

View File

@ -118,5 +118,5 @@ namespace Kernel
friend class Scheduler; friend class Scheduler;
}; };
} }

View File

@ -9,7 +9,7 @@ namespace Kernel
{ {
public: public:
BAN::Time get_current_time(); BAN::Time get_current_time();
private: private:
bool is_update_in_progress(); bool is_update_in_progress();
uint8_t read_register8(uint8_t reg); uint8_t read_register8(uint8_t reg);

View File

@ -12,7 +12,6 @@ namespace Kernel
return BAN::RefPtr<ZeroDevice>::adopt(result); return BAN::RefPtr<ZeroDevice>::adopt(result);
} }
BAN::ErrorOr<size_t> ZeroDevice::read_impl(off_t, void* buffer, size_t bytes) BAN::ErrorOr<size_t> ZeroDevice::read_impl(off_t, void* buffer, size_t bytes)
{ {
memset(buffer, 0, bytes); memset(buffer, 0, bytes);

View File

@ -12,7 +12,7 @@ namespace Kernel
return BAN::Error::from_errno(ENOMEM); return BAN::Error::from_errno(ENOMEM);
return BAN::RefPtr<Inode>::adopt(pipe); return BAN::RefPtr<Inode>::adopt(pipe);
} }
Pipe::Pipe(const Credentials& credentials) Pipe::Pipe(const Credentials& credentials)
: m_uid(credentials.euid()) : m_uid(credentials.euid())
, m_gid(credentials.egid()) , m_gid(credentials.egid())
@ -29,7 +29,7 @@ namespace Kernel
ASSERT(m_writing_count > 0); ASSERT(m_writing_count > 0);
m_writing_count++; m_writing_count++;
} }
void Pipe::close_writing() void Pipe::close_writing()
{ {
LockGuard _(m_lock); LockGuard _(m_lock);
@ -63,7 +63,7 @@ namespace Kernel
return to_copy; return to_copy;
} }
BAN::ErrorOr<size_t> Pipe::write_impl(off_t, const void* buffer, size_t count) BAN::ErrorOr<size_t> Pipe::write_impl(off_t, const void* buffer, size_t count)
{ {
LockGuard _(m_lock); LockGuard _(m_lock);
@ -81,5 +81,5 @@ namespace Kernel
return count; return count;
} }
} }

View File

@ -6,7 +6,7 @@ namespace Kernel
{ {
/* /*
RAM INODE RAM INODE
*/ */
@ -68,7 +68,7 @@ namespace Kernel
} }
/* /*
RAM DIRECTORY INODE RAM DIRECTORY INODE
*/ */
@ -217,7 +217,7 @@ namespace Kernel
} }
/* /*
RAM SYMLINK INODE RAM SYMLINK INODE
*/ */

View File

@ -35,7 +35,7 @@ namespace Kernel
auto* tmpfs = MUST(RamFileSystem::create(1024 * 1024, tmpfs_mode, 0, 0)); auto* tmpfs = MUST(RamFileSystem::create(1024 * 1024, tmpfs_mode, 0, 0));
MUST(s_instance->mount(root_creds, tmpfs, "/tmp")); MUST(s_instance->mount(root_creds, tmpfs, "/tmp"));
} }
VirtualFileSystem& VirtualFileSystem::get() VirtualFileSystem& VirtualFileSystem::get()
{ {
ASSERT(s_instance); ASSERT(s_instance);

View File

@ -245,7 +245,7 @@ namespace Kernel
result.m_pitch = header.glyph_size / header.height; result.m_pitch = header.glyph_size / header.height;
return result; return result;
} }
bool Font::has_glyph(uint32_t codepoint) const bool Font::has_glyph(uint32_t codepoint) const
{ {
return m_glyph_offsets.contains(codepoint); return m_glyph_offsets.contains(codepoint);

View File

@ -121,7 +121,7 @@ namespace Kernel::Input
} }
m_command_queue.push(byte); m_command_queue.push(byte);
} }
void PS2Keyboard::append_command_queue(uint8_t byte1, uint8_t byte2) void PS2Keyboard::append_command_queue(uint8_t byte1, uint8_t byte2)
{ {
if (m_command_queue.size() + 2 > m_command_queue.capacity()) if (m_command_queue.size() + 2 > m_command_queue.capacity())

View File

@ -59,7 +59,7 @@ namespace Kernel
return page; return page;
return 0; return 0;
} }
void Heap::release_page(paddr_t addr) void Heap::release_page(paddr_t addr)
{ {
LockGuard _(m_lock); LockGuard _(m_lock);

View File

@ -192,7 +192,7 @@ static void* kmalloc_fixed()
// allocate the node on top of free list // allocate the node on top of free list
auto* node = info.free_list_head; auto* node = info.free_list_head;
ASSERT(node->next == kmalloc_fixed_info::node::invalid); ASSERT(node->next == kmalloc_fixed_info::node::invalid);
// remove the node from free list // remove the node from free list
if (info.free_list_head->prev != kmalloc_fixed_info::node::invalid) if (info.free_list_head->prev != kmalloc_fixed_info::node::invalid)
{ {
@ -326,7 +326,7 @@ void* kmalloc(size_t size, size_t align, bool force_indentity_map)
if (ptrdiff_t rem = size % s_kmalloc_min_align) if (ptrdiff_t rem = size % s_kmalloc_min_align)
size += s_kmalloc_min_align - rem; size += s_kmalloc_min_align - rem;
if (void* res = kmalloc_impl(size, align)) if (void* res = kmalloc_impl(size, align))
return res; return res;

View File

@ -7,7 +7,6 @@
namespace Kernel namespace Kernel
{ {
OpenFileDescriptorSet::OpenFileDescriptorSet(const Credentials& credentials) OpenFileDescriptorSet::OpenFileDescriptorSet(const Credentials& credentials)
: m_credentials(credentials) : m_credentials(credentials)
{ {

View File

@ -995,7 +995,7 @@ namespace Kernel
auto inode = TRY(m_open_file_descriptors.inode_of(fd)); auto inode = TRY(m_open_file_descriptors.inode_of(fd));
if (!inode->is_tty()) if (!inode->is_tty())
return BAN::Error::from_errno(ENOTTY); return BAN::Error::from_errno(ENOTTY);
if ((TTY*)inode.ptr() != m_controlling_terminal.ptr()) if ((TTY*)inode.ptr() != m_controlling_terminal.ptr())
return BAN::Error::from_errno(ENOTTY); return BAN::Error::from_errno(ENOTTY);

View File

@ -2,13 +2,13 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#if UINT32_MAX == UINTPTR_MAX #if UINT32_MAX == UINTPTR_MAX
#define STACK_CHK_GUARD 0xe2dee396 #define STACK_CHK_GUARD 0xe2dee396
#else #else
#define STACK_CHK_GUARD 0x595e9fbd94fda766 #define STACK_CHK_GUARD 0x595e9fbd94fda766
#endif #endif
uintptr_t __stack_chk_guard = STACK_CHK_GUARD; uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
__BEGIN_DECLS __BEGIN_DECLS

View File

@ -304,7 +304,7 @@ namespace Kernel
execute_current_thread(); execute_current_thread();
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }
void Scheduler::unblock_threads(Semaphore* semaphore) void Scheduler::unblock_threads(Semaphore* semaphore)
{ {
CriticalScope critical; CriticalScope critical;

View File

@ -323,5 +323,5 @@ namespace Kernel
return {}; return {};
} }
} }

View File

@ -181,7 +181,7 @@ namespace Kernel
{ {
return s_has_devices; return s_has_devices;
} }
void Serial::putchar(char c) void Serial::putchar(char c)
{ {
while (!(IO::inb(m_port + 5) & 0x20)) while (!(IO::inb(m_port + 5) & 0x20))
@ -275,7 +275,7 @@ namespace Kernel
if (m_serial.port() == COM2_PORT) if (m_serial.port() == COM2_PORT)
update_com(s_com2, s_com2_input); update_com(s_com2, s_com2_input);
} }
uint32_t SerialTTY::width() const uint32_t SerialTTY::width() const
{ {
return m_serial.width(); return m_serial.width();
@ -285,7 +285,7 @@ namespace Kernel
{ {
return m_serial.height(); return m_serial.height();
} }
void SerialTTY::putchar(uint8_t ch) void SerialTTY::putchar(uint8_t ch)
{ {
m_serial.putchar(ch); m_serial.putchar(ch);

View File

@ -57,7 +57,6 @@ VesaTerminalDriver* VesaTerminalDriver::create()
return driver; return driver;
} }
VesaTerminalDriver::~VesaTerminalDriver() VesaTerminalDriver::~VesaTerminalDriver()
{ {
PageTable::kernel().unmap_range(m_address, m_pitch * m_height); PageTable::kernel().unmap_range(m_address, m_pitch * m_height);

View File

@ -25,7 +25,6 @@ namespace Kernel
memcpy((void*)rsp, (void*)&value, sizeof(uintptr_t)); memcpy((void*)rsp, (void*)&value, sizeof(uintptr_t));
} }
Thread::TerminateBlocker::TerminateBlocker(Thread& thread) Thread::TerminateBlocker::TerminateBlocker(Thread& thread)
: m_thread(thread) : m_thread(thread)
{ {

View File

@ -47,7 +47,7 @@ namespace Kernel
void PIT::initialize() void PIT::initialize()
{ {
constexpr uint16_t timer_reload = BASE_FREQUENCY / TICKS_PER_SECOND; constexpr uint16_t timer_reload = BASE_FREQUENCY / TICKS_PER_SECOND;
IO::outb(PIT_CTL, SELECT_CHANNEL0 | ACCESS_LO | ACCESS_HI | MODE_SQUARE_WAVE); IO::outb(PIT_CTL, SELECT_CHANNEL0 | ACCESS_LO | ACCESS_HI | MODE_SQUARE_WAVE);
IO::outb(TIMER0_CTL, (timer_reload >> 0) & 0xff); IO::outb(TIMER0_CTL, (timer_reload >> 0) & 0xff);

View File

@ -169,7 +169,7 @@ static void init2(void*)
PCI::initialize(); PCI::initialize();
dprintln("PCI initialized"); dprintln("PCI initialized");
VirtualFileSystem::initialize(cmdline.root); VirtualFileSystem::initialize(cmdline.root);
if (auto res = PS2Controller::initialize(); res.is_error()) if (auto res = PS2Controller::initialize(); res.is_error())

View File

@ -10,14 +10,14 @@ extern "C"
uint32_t line; uint32_t line;
uint32_t column; uint32_t column;
}; };
struct type_descriptor struct type_descriptor
{ {
uint16_t kind; uint16_t kind;
uint16_t info; uint16_t info;
char name[1]; char name[1];
}; };
struct type_mismatch_data struct type_mismatch_data
{ {
source_location location; source_location location;
@ -25,7 +25,7 @@ extern "C"
uint8_t alignment; uint8_t alignment;
uint8_t type_check_kind; uint8_t type_check_kind;
}; };
struct out_of_bounds_data struct out_of_bounds_data
{ {
source_location location; source_location location;

View File

@ -24,7 +24,7 @@ int closedir(DIR* dirp)
errno = EBADF; errno = EBADF;
return -1; return -1;
} }
close(dirp->fd); close(dirp->fd);
dirp->fd = -1; dirp->fd = -1;
free(dirp); free(dirp);

View File

@ -49,7 +49,6 @@ size_t strxfrm_l(char* __restrict s1, const char* __restrict s2, size_t n, local
const char* strerrorname_np(int error); const char* strerrorname_np(int error);
const char* strerrordesc_np(int error); const char* strerrordesc_np(int error);
__END_DECLS __END_DECLS
#endif #endif

View File

@ -87,7 +87,6 @@ struct stat
#define UTIME_NOW 1000000001 #define UTIME_NOW 1000000001
#define UTIME_OMIT 1000000002 #define UTIME_OMIT 1000000002
int chmod(const char* path, mode_t mode); int chmod(const char* path, mode_t mode);
int fchmod(int fildes, mode_t mode); int fchmod(int fildes, mode_t mode);
int fchmodat(int fd, const char* path, mode_t mode, int flag); int fchmodat(int fd, const char* path, mode_t mode, int flag);

View File

@ -77,7 +77,7 @@ static void integer_to_string(char* buffer, T value, int base, bool upper, forma
prefix[1] = 'x'; prefix[1] = 'x';
} }
} }
while (value || offset < digits) while (value || offset < digits)
{ {
buffer[offset++] = digit_char(value % base, upper); buffer[offset++] = digit_char(value % base, upper);
@ -171,7 +171,7 @@ static void floating_point_to_string(char* buffer, T value, bool upper, const fo
return; return;
} }
buffer[offset++] = '.'; buffer[offset++] = '.';
// Add the 'percision' digits after decimal point // Add the 'percision' digits after decimal point
for (int i = 0; i < percision; i++) for (int i = 0; i < percision; i++)
{ {
@ -193,7 +193,7 @@ static void floating_point_to_exponent_string(char* buffer, T value, bool upper,
int percision = 6; int percision = 6;
if (options.percision != -1) if (options.percision != -1)
percision = options.percision; percision = options.percision;
int offset = 0; int offset = 0;
// Add sign if needed // Add sign if needed
@ -465,7 +465,6 @@ extern "C" int printf_impl(const char* format, va_list arguments, int (*putc_fun
format++; format++;
} }
} }
return written; return written;
} }

View File

@ -50,7 +50,7 @@ struct passwd* getpwent(void)
if (!open_pwent()) if (!open_pwent())
return nullptr; return nullptr;
clear_pwent(s_pwent_struct); clear_pwent(s_pwent_struct);
BAN::String line; BAN::String line;
while (true) while (true)
{ {

View File

@ -62,7 +62,7 @@ FILE* fdopen(int fd, const char* mode)
return &s_files[i]; return &s_files[i];
} }
} }
errno = EMFILE; errno = EMFILE;
return nullptr; return nullptr;
} }
@ -90,7 +90,7 @@ int fflush(FILE* file)
if (file->buffer_index == 0) if (file->buffer_index == 0)
return 0; return 0;
if (syscall(SYS_WRITE, file->fd, file->buffer, file->buffer_index) < 0) if (syscall(SYS_WRITE, file->fd, file->buffer, file->buffer_index) < 0)
{ {
file->error = true; file->error = true;
@ -105,7 +105,7 @@ int fgetc(FILE* file)
{ {
if (file->eof) if (file->eof)
return EOF; return EOF;
unsigned char c; unsigned char c;
long ret = syscall(SYS_READ, file->fd, &c, 1); long ret = syscall(SYS_READ, file->fd, &c, 1);
@ -114,7 +114,7 @@ int fgetc(FILE* file)
file->error = true; file->error = true;
return EOF; return EOF;
} }
if (ret == 0) if (ret == 0)
{ {
file->eof = true; file->eof = true;
@ -217,7 +217,7 @@ FILE* fopen(const char* pathname, const char* mode)
return &s_files[i]; return &s_files[i];
} }
} }
errno = EMFILE; errno = EMFILE;
return nullptr; return nullptr;
} }
@ -293,7 +293,7 @@ int fseeko(FILE* file, off_t offset, int whence)
long ret = syscall(SYS_SEEK, file->fd, offset, whence); long ret = syscall(SYS_SEEK, file->fd, offset, whence);
if (ret < 0) if (ret < 0)
return -1; return -1;
file->eof = false; file->eof = false;
return 0; return 0;
} }
@ -353,7 +353,7 @@ char* gets(char* buffer)
return nullptr; return nullptr;
unsigned char* ubuffer = (unsigned char*)buffer; unsigned char* ubuffer = (unsigned char*)buffer;
int first = fgetc(stdin); int first = fgetc(stdin);
if (first == EOF) if (first == EOF)
return nullptr; return nullptr;
@ -529,7 +529,7 @@ int vsprintf(char* buffer, const char* format, va_list arguments)
{ {
if (buffer == nullptr) if (buffer == nullptr)
return printf_impl(format, arguments, [](int, void*) { return 0; }, nullptr); return printf_impl(format, arguments, [](int, void*) { return 0; }, nullptr);
int ret = printf_impl(format, arguments, int ret = printf_impl(format, arguments,
[](int c, void* _buffer) [](int c, void* _buffer)
{ {

View File

@ -205,7 +205,6 @@ void free(void* ptr)
syscall(SYS_FREE, ptr); syscall(SYS_FREE, ptr);
} }
// Constants and algorithm from https://en.wikipedia.org/wiki/Permuted_congruential_generator // Constants and algorithm from https://en.wikipedia.org/wiki/Permuted_congruential_generator
static uint64_t s_rand_state = 0x4d595df4d0f33173; static uint64_t s_rand_state = 0x4d595df4d0f33173;

View File

@ -273,7 +273,6 @@ const char* strerrordesc_np(int error)
return "Unknown error"; return "Unknown error";
} }
size_t strlen(const char* str) size_t strlen(const char* str)
{ {
size_t len = 0; size_t len = 0;

View File

@ -32,11 +32,11 @@ long syscall(long syscall, ...)
uintptr_t arg3 = va_arg(args, uintptr_t); uintptr_t arg3 = va_arg(args, uintptr_t);
uintptr_t arg4 = va_arg(args, uintptr_t); uintptr_t arg4 = va_arg(args, uintptr_t);
uintptr_t arg5 = va_arg(args, uintptr_t); uintptr_t arg5 = va_arg(args, uintptr_t);
va_end(args); va_end(args);
long ret = Kernel::syscall(syscall, arg1, arg2, arg3, arg4, arg5); long ret = Kernel::syscall(syscall, arg1, arg2, arg3, arg4, arg5);
if (ret < 0) if (ret < 0)
{ {
errno = -ret; errno = -ret;
@ -78,7 +78,7 @@ int execl(const char* pathname, const char* arg0, ...)
char* temp = nullptr; char* temp = nullptr;
return execv(pathname, &temp); return execv(pathname, &temp);
} }
va_list ap; va_list ap;
va_start(ap, arg0); va_start(ap, arg0);
int argc = 1; int argc = 1;

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
qemu-system-$BANAN_ARCH \ qemu-system-$BANAN_ARCH \
-m 128 \ -m 128 \
-smp 2 \ -smp 2 \

View File

@ -51,9 +51,9 @@ void list_directory(const char* path)
DIR* dirp = opendir(path); DIR* dirp = opendir(path);
if (dirp == nullptr) if (dirp == nullptr)
return perror("opendir"); return perror("opendir");
errno = 0; errno = 0;
bool first = true; bool first = true;
while (auto* dirent = readdir(dirp)) while (auto* dirent = readdir(dirp))
{ {