From d9713723c962700d1ede04c85a186d36b0e79583 Mon Sep 17 00:00:00 2001 From: apio Date: Mon, 23 Dec 2024 22:56:56 +0100 Subject: [PATCH] tools: Update sources list and run clang-format --- kernel/src/Log.cpp | 3 +-- kernel/src/arch/x86_64/PCI.cpp | 2 +- kernel/src/fs/devices/FramebufferDevice.cpp | 2 +- kernel/src/video/TextConsole.cpp | 4 ++-- libc/include/bits/errno-return.h | 2 +- libc/include/bits/makedev.h | 2 +- libc/include/bits/modes.h | 2 +- libc/include/bits/timespec.h | 10 ++-------- libc/include/sys/wait.h | 8 ++++---- libluna/include/luna/Move.h | 2 +- libluna/src/CString.cpp | 9 +++------ tools/sources.sh | 2 +- 12 files changed, 19 insertions(+), 29 deletions(-) diff --git a/kernel/src/Log.cpp b/kernel/src/Log.cpp index 17c8bd59..18dbdeed 100644 --- a/kernel/src/Log.cpp +++ b/kernel/src/Log.cpp @@ -77,8 +77,7 @@ static void log_text_console(LogLevel level, const char* format, va_list origin) TextConsole::set_foreground(WHITE); // NOTE: Same as above. - auto rc = cstyle_format( - format, [](char c, void*) -> Result { return TextConsole::putchar(c); }, nullptr, ap); + auto rc = cstyle_format(format, [](char c, void*) -> Result { return TextConsole::putchar(c); }, nullptr, ap); if (rc.has_error()) { TextConsole::wprint(L"Invalid UTF-8 in log message"); } diff --git a/kernel/src/arch/x86_64/PCI.cpp b/kernel/src/arch/x86_64/PCI.cpp index 16fd0815..6f2253ec 100644 --- a/kernel/src/arch/x86_64/PCI.cpp +++ b/kernel/src/arch/x86_64/PCI.cpp @@ -8,7 +8,7 @@ static inline constexpr u32 make_pci_address(const PCI::Device::Address& address, u32 field) { - return 0x80000000 | (address.bus << 16) | (address.slot << 11) | (address.function << 8) | ((field)&0xFC); + return 0x80000000 | (address.bus << 16) | (address.slot << 11) | (address.function << 8) | ((field) & 0xFC); } namespace PCI diff --git a/kernel/src/fs/devices/FramebufferDevice.cpp b/kernel/src/fs/devices/FramebufferDevice.cpp index 7617b914..da06d32a 100644 --- a/kernel/src/fs/devices/FramebufferDevice.cpp +++ b/kernel/src/fs/devices/FramebufferDevice.cpp @@ -3,8 +3,8 @@ #include "memory/SharedMemory.h" #include "video/Framebuffer.h" #include -#include #include +#include Result FramebufferDevice::create() { diff --git a/kernel/src/video/TextConsole.cpp b/kernel/src/video/TextConsole.cpp index cc034927..5c192a96 100644 --- a/kernel/src/video/TextConsole.cpp +++ b/kernel/src/video/TextConsole.cpp @@ -207,8 +207,8 @@ namespace TextConsole { va_list ap; va_start(ap, format); - const usize rc = TRY(cstyle_format( - format, [](char c, void*) -> Result { return putchar(c); }, nullptr, ap)); + const usize rc = + TRY(cstyle_format(format, [](char c, void*) -> Result { return putchar(c); }, nullptr, ap)); va_end(ap); return rc; } diff --git a/libc/include/bits/errno-return.h b/libc/include/bits/errno-return.h index 9eb6931a..1fb69349 100644 --- a/libc/include/bits/errno-return.h +++ b/libc/include/bits/errno-return.h @@ -11,7 +11,7 @@ if (value < 0) \ { \ errno = (int)(-value); \ - return (type)-1; \ + return (type) - 1; \ } \ return (type)value; \ } while (0) diff --git a/libc/include/bits/makedev.h b/libc/include/bits/makedev.h index 3446a013..ed7f2a73 100644 --- a/libc/include/bits/makedev.h +++ b/libc/include/bits/makedev.h @@ -4,7 +4,7 @@ #include #define luna_dev_major(dev) (__u32_t)((dev) >> 32) -#define luna_dev_minor(dev) (__u32_t)((dev)&0xffffffff) +#define luna_dev_minor(dev) (__u32_t)((dev) & 0xffffffff) #define luna_dev_makedev(maj, min) (((__u64_t)(maj) << 32) | (__u64_t)(min)) #endif diff --git a/libc/include/bits/modes.h b/libc/include/bits/modes.h index b46df7c2..64e2b247 100644 --- a/libc/include/bits/modes.h +++ b/libc/include/bits/modes.h @@ -12,7 +12,7 @@ #define S_IFCHR 050000 #define S_IFSOCK 060000 -#define __CHECK_TYPE(mode, type) (((mode)&S_IFMT) == type) +#define __CHECK_TYPE(mode, type) (((mode) & S_IFMT) == type) #define S_ISREG(mode) __CHECK_TYPE(mode, S_IFREG) #define S_ISDIR(mode) __CHECK_TYPE(mode, S_IFDIR) diff --git a/libc/include/bits/timespec.h b/libc/include/bits/timespec.h index 4a1896cb..f82c2def 100644 --- a/libc/include/bits/timespec.h +++ b/libc/include/bits/timespec.h @@ -34,12 +34,6 @@ struct timeval } while (0); #endif -#define TIMEVAL_TO_TIMESPEC(x) \ - { \ - .tv_sec = (x).tv_sec, .tv_nsec = (x).tv_usec * 1000 \ - } -#define TIMESPEC_TO_TIMEVAL(x) \ - { \ - .tv_sec = (x).tv_sec, .tv_usec = (x).tv_nsec / 1000 \ - } +#define TIMEVAL_TO_TIMESPEC(x) { .tv_sec = (x).tv_sec, .tv_nsec = (x).tv_usec * 1000 } +#define TIMESPEC_TO_TIMEVAL(x) { .tv_sec = (x).tv_sec, .tv_usec = (x).tv_nsec / 1000 } #endif diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h index a10d9bf1..c3b7d0b6 100644 --- a/libc/include/sys/wait.h +++ b/libc/include/sys/wait.h @@ -6,10 +6,10 @@ #include #include -#define WIFEXITED(ret) (((ret)&_SIGBIT) == 0) -#define WEXITSTATUS(ret) ((ret)&0xff) -#define WIFSIGNALED(ret) (((ret)&_SIGBIT) == _SIGBIT) -#define WTERMSIG(ret) ((ret)&0xff) +#define WIFEXITED(ret) (((ret) & _SIGBIT) == 0) +#define WEXITSTATUS(ret) ((ret) & 0xff) +#define WIFSIGNALED(ret) (((ret) & _SIGBIT) == _SIGBIT) +#define WTERMSIG(ret) ((ret) & 0xff) #ifdef __cplusplus extern "C" diff --git a/libluna/include/luna/Move.h b/libluna/include/luna/Move.h index 6a88f7b0..de9c10bc 100644 --- a/libluna/include/luna/Move.h +++ b/libluna/include/luna/Move.h @@ -2,5 +2,5 @@ template inline T&& move(T& lvalue) { - return (T &&) lvalue; + return (T&&)lvalue; } diff --git a/libluna/src/CString.cpp b/libluna/src/CString.cpp index 249bd774..aaa984d4 100644 --- a/libluna/src/CString.cpp +++ b/libluna/src/CString.cpp @@ -60,16 +60,14 @@ extern "C" usize strlen(const char* str) { const char* i = str; - for (; *i; ++i) - ; + for (; *i; ++i); return (usize)(i - str); } usize strnlen(const char* str, usize max) { const char* i = str; - for (; *i && max; ++i, --max) - ; + for (; *i && max; ++i, --max); return (usize)(i - str); } @@ -108,8 +106,7 @@ extern "C" usize wcslen(const wchar_t* str) { const wchar_t* i = str; - for (; *i; ++i) - ; + for (; *i; ++i); return (usize)(i - str); } diff --git a/tools/sources.sh b/tools/sources.sh index 752d1883..d81f934f 100755 --- a/tools/sources.sh +++ b/tools/sources.sh @@ -4,7 +4,7 @@ source $(dirname $0)/env.sh cd $LUNA_ROOT -FOLDERS=(kernel libc libos libui libluna apps shell tests) +FOLDERS=(kernel libc libos gui libluna utils shell tests system) SOURCES=($(find ${FOLDERS[@]} -type f -name "*.cpp")) SOURCES+=($(find ${FOLDERS[@]} -type f -name "*.h"))