diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2023-01-03 15:30:44 +0100 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2023-01-07 10:01:37 -0700 |
commit | 32810503595a83d3bb4c709759224223f2137e0c (patch) | |
tree | b39d1699b31e65501c869f70ad51b47603b08508 | |
parent | d575cfda613197a7e090ee8dee053e48df17d730 (diff) | |
download | serenity-32810503595a83d3bb4c709759224223f2137e0c.zip |
Everywhere: Remove "LibC/" includes, add lint-rule against it
-rw-r--r-- | AK/Error.h | 2 | ||||
-rwxr-xr-x | Meta/check-style.py | 16 | ||||
-rw-r--r-- | Tests/LibC/TestMalloc.cpp | 2 | ||||
-rw-r--r-- | Tests/LibC/TestMemalign.cpp | 2 | ||||
-rw-r--r-- | Tests/LibELF/test-elf.cpp | 2 | ||||
-rw-r--r-- | Tests/LibRegex/RegexLibC.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/CrashReporter/main.cpp | 4 | ||||
-rw-r--r-- | Userland/Applications/Debugger/main.cpp | 2 | ||||
-rw-r--r-- | Userland/DynamicLoader/main.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibC/bits/stdio_file_implementation.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibC/cxxabi.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibC/ifaddrs.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibC/math.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibC/net.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibC/stdio.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibDebug/DebugSession.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibDebug/ProcessInspector.h | 2 | ||||
-rw-r--r-- | Userland/Services/SpiceAgent/SpiceAgent.cpp | 4 | ||||
-rw-r--r-- | Userland/Services/SpiceAgent/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Utilities/functrace.cpp | 2 | ||||
-rw-r--r-- | Userland/Utilities/strace.cpp | 2 |
21 files changed, 45 insertions, 31 deletions
diff --git a/AK/Error.h b/AK/Error.h index fa6e4e4ae6..0993f337df 100644 --- a/AK/Error.h +++ b/AK/Error.h @@ -11,7 +11,7 @@ #include <AK/Variant.h> #if defined(AK_OS_SERENITY) && defined(KERNEL) -# include <LibC/errno_codes.h> +# include <errno_codes.h> #else # include <errno.h> # include <string.h> diff --git a/Meta/check-style.py b/Meta/check-style.py index c23094e227..971f724d90 100755 --- a/Meta/check-style.py +++ b/Meta/check-style.py @@ -28,6 +28,11 @@ LICENSE_HEADER_CHECK_EXCLUDES = { 'Userland/Libraries/LibCpp/Tests/parser/', 'Userland/Libraries/LibCpp/Tests/preprocessor/' } +LIBC_CHECK_EXCLUDES = { + 'Kernel/', + 'Userland/Libraries/LibELF/', + 'Userland/Libraries/LibRegex/' +} # We check that "#pragma once" is present PRAGMA_ONCE_STRING = '#pragma once' @@ -38,6 +43,9 @@ PRAGMA_ONCE_CHECK_EXCLUDES = { # We make sure that there's a blank line before and after pragma once GOOD_PRAGMA_ONCE_PATTERN = re.compile('(^|\\S\n\n)#pragma once(\n\n\\S.|$)') +# LibC is supposed to be a system library; don't mention the directory. +BAD_INCLUDE_LIBC = re.compile("# *include <LibC/") + def should_check_file(filename): if not filename.endswith('.cpp') and not filename.endswith('.h'): @@ -63,6 +71,7 @@ def run(): errors_license = [] errors_pragma_once_bad = [] errors_pragma_once_missing = [] + errors_include_libc = [] for filename in find_files_here_or_argv(): with open(filename, "r") as f: @@ -83,6 +92,9 @@ def run(): else: # Bad, the '#pragma once' is missing completely. errors_pragma_once_missing.append(filename) + if not any(filename.startswith(forbidden_prefix) for forbidden_prefix in LIBC_CHECK_EXCLUDES): + if BAD_INCLUDE_LIBC.search(file_content): + errors_include_libc.append(filename) if errors_license: print("Files with bad licenses:", " ".join(errors_license)) @@ -90,8 +102,10 @@ def run(): print("Files without #pragma once:", " ".join(errors_pragma_once_missing)) if errors_pragma_once_bad: print("Files with a bad #pragma once:", " ".join(errors_pragma_once_bad)) + if errors_include_libc: + print("Files that include a LibC header using #include <LibC/...>:", " ".join(errors_include_libc)) - if errors_license or errors_pragma_once_missing or errors_pragma_once_bad: + if errors_license or errors_pragma_once_missing or errors_pragma_once_bad or errors_include_libc: sys.exit(1) diff --git a/Tests/LibC/TestMalloc.cpp b/Tests/LibC/TestMalloc.cpp index 31d100ac90..af4e979077 100644 --- a/Tests/LibC/TestMalloc.cpp +++ b/Tests/LibC/TestMalloc.cpp @@ -6,8 +6,8 @@ #include <LibTest/TestCase.h> -#include <LibC/mallocdefs.h> #include <errno.h> +#include <mallocdefs.h> #include <stdlib.h> TEST_CASE(malloc_limits) diff --git a/Tests/LibC/TestMemalign.cpp b/Tests/LibC/TestMemalign.cpp index 01069ac4e6..51840fec5a 100644 --- a/Tests/LibC/TestMemalign.cpp +++ b/Tests/LibC/TestMemalign.cpp @@ -6,7 +6,7 @@ #include <LibTest/TestCase.h> -#include <LibC/mallocdefs.h> +#include <mallocdefs.h> #include <stdlib.h> static constexpr size_t runs = 5000; diff --git a/Tests/LibELF/test-elf.cpp b/Tests/LibELF/test-elf.cpp index 97c75c02d0..8b4331ad42 100644 --- a/Tests/LibELF/test-elf.cpp +++ b/Tests/LibELF/test-elf.cpp @@ -4,9 +4,9 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibC/elf.h> #include <LibCore/File.h> #include <LibTest/TestCase.h> +#include <elf.h> #include <fcntl.h> #include <stdio.h> #include <string.h> diff --git a/Tests/LibRegex/RegexLibC.cpp b/Tests/LibRegex/RegexLibC.cpp index 1ff52499ef..658fb1e8f9 100644 --- a/Tests/LibRegex/RegexLibC.cpp +++ b/Tests/LibRegex/RegexLibC.cpp @@ -8,7 +8,7 @@ #include <AK/StringBuilder.h> #include <AK/Vector.h> -#include <LibC/regex.h> +#include <regex.h> #include <stdio.h> TEST_CASE(catch_all) diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index e2553e9aec..feb28fd3a3 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -11,8 +11,6 @@ #include <AK/Types.h> #include <AK/URL.h> #include <Applications/CrashReporter/CrashReporterWindowGML.h> -#include <LibC/serenity.h> -#include <LibC/spawn.h> #include <LibCore/ArgsParser.h> #include <LibCore/File.h> #include <LibCore/System.h> @@ -39,6 +37,8 @@ #include <LibGUI/Window.h> #include <LibMain/Main.h> #include <LibThreading/BackgroundAction.h> +#include <serenity.h> +#include <spawn.h> #include <string.h> #include <unistd.h> diff --git a/Userland/Applications/Debugger/main.cpp b/Userland/Applications/Debugger/main.cpp index 56374ae4e3..0c17c9431a 100644 --- a/Userland/Applications/Debugger/main.cpp +++ b/Userland/Applications/Debugger/main.cpp @@ -11,7 +11,6 @@ #include <AK/Platform.h> #include <AK/StringBuilder.h> #include <AK/Try.h> -#include <LibC/sys/arch/regs.h> #include <LibCore/ArgsParser.h> #include <LibCore/System.h> #include <LibDebug/DebugInfo.h> @@ -23,6 +22,7 @@ #include <signal.h> #include <stdio.h> #include <stdlib.h> +#include <sys/arch/regs.h> #include <unistd.h> RefPtr<Line::Editor> editor; diff --git a/Userland/DynamicLoader/main.cpp b/Userland/DynamicLoader/main.cpp index 5e6c0a5d42..5e61355a86 100644 --- a/Userland/DynamicLoader/main.cpp +++ b/Userland/DynamicLoader/main.cpp @@ -4,11 +4,11 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibC/sys/internals.h> -#include <LibC/unistd.h> #include <LibELF/AuxiliaryVector.h> #include <LibELF/DynamicLinker.h> #include <LibELF/Relocation.h> +#include <sys/internals.h> +#include <unistd.h> char* __static_environ[] = { nullptr }; // We don't get the environment without some libc workarounds.. diff --git a/Userland/Libraries/LibC/bits/stdio_file_implementation.h b/Userland/Libraries/LibC/bits/stdio_file_implementation.h index 555cdcbc97..2bf8aa2e20 100644 --- a/Userland/Libraries/LibC/bits/stdio_file_implementation.h +++ b/Userland/Libraries/LibC/bits/stdio_file_implementation.h @@ -9,9 +9,9 @@ #include <AK/Array.h> #include <AK/IntrusiveList.h> #include <AK/Types.h> -#include <LibC/bits/FILE.h> -#include <LibC/bits/pthread_integration.h> -#include <LibC/bits/wchar.h> +#include <bits/FILE.h> +#include <bits/pthread_integration.h> +#include <bits/wchar.h> #include <pthread.h> #include <sys/types.h> diff --git a/Userland/Libraries/LibC/cxxabi.cpp b/Userland/Libraries/LibC/cxxabi.cpp index 4da6b2fe14..6b23aec013 100644 --- a/Userland/Libraries/LibC/cxxabi.cpp +++ b/Userland/Libraries/LibC/cxxabi.cpp @@ -9,9 +9,9 @@ #include <AK/Debug.h> #include <AK/Format.h> #include <AK/NeverDestroyed.h> -#include <LibC/bits/pthread_integration.h> -#include <LibC/mallocdefs.h> #include <assert.h> +#include <bits/pthread_integration.h> +#include <mallocdefs.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> diff --git a/Userland/Libraries/LibC/ifaddrs.cpp b/Userland/Libraries/LibC/ifaddrs.cpp index a42345a6e4..697579a3b6 100644 --- a/Userland/Libraries/LibC/ifaddrs.cpp +++ b/Userland/Libraries/LibC/ifaddrs.cpp @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibC/errno.h> -#include <LibC/ifaddrs.h> +#include <errno.h> +#include <ifaddrs.h> int getifaddrs(struct ifaddrs**) { diff --git a/Userland/Libraries/LibC/math.cpp b/Userland/Libraries/LibC/math.cpp index ada821963a..f7ad62996e 100644 --- a/Userland/Libraries/LibC/math.cpp +++ b/Userland/Libraries/LibC/math.cpp @@ -16,7 +16,7 @@ #include <AK/Math.h> #include <AK/Platform.h> #include <AK/StdLibExtras.h> -#include <LibC/assert.h> +#include <assert.h> #include <fenv.h> #include <math.h> #include <stdint.h> diff --git a/Userland/Libraries/LibC/net.cpp b/Userland/Libraries/LibC/net.cpp index 9a6b113529..f147c6bb23 100644 --- a/Userland/Libraries/LibC/net.cpp +++ b/Userland/Libraries/LibC/net.cpp @@ -4,9 +4,9 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibC/errno.h> -#include <LibC/net/if.h> -#include <LibC/netinet/in.h> +#include <errno.h> +#include <net/if.h> +#include <netinet/in.h> const in6_addr in6addr_any = IN6ADDR_ANY_INIT; const in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; diff --git a/Userland/Libraries/LibC/stdio.cpp b/Userland/Libraries/LibC/stdio.cpp index ed34dd8101..4546a533c6 100644 --- a/Userland/Libraries/LibC/stdio.cpp +++ b/Userland/Libraries/LibC/stdio.cpp @@ -11,9 +11,9 @@ #include <AK/PrintfImplementation.h> #include <AK/ScopedValueRollback.h> #include <AK/StdLibExtras.h> -#include <LibC/bits/mutex_locker.h> -#include <LibC/bits/stdio_file_implementation.h> #include <assert.h> +#include <bits/mutex_locker.h> +#include <bits/stdio_file_implementation.h> #include <errno.h> #include <fcntl.h> #include <stdarg.h> diff --git a/Userland/Libraries/LibDebug/DebugSession.h b/Userland/Libraries/LibDebug/DebugSession.h index ed6e3750f8..dad0e4bd2c 100644 --- a/Userland/Libraries/LibDebug/DebugSession.h +++ b/Userland/Libraries/LibDebug/DebugSession.h @@ -13,12 +13,12 @@ #include <AK/NonnullRefPtr.h> #include <AK/Optional.h> #include <AK/OwnPtr.h> -#include <LibC/sys/arch/regs.h> #include <LibCore/MappedFile.h> #include <LibDebug/DebugInfo.h> #include <LibDebug/ProcessInspector.h> #include <signal.h> #include <stdio.h> +#include <sys/arch/regs.h> #include <sys/ptrace.h> #include <sys/wait.h> #include <unistd.h> diff --git a/Userland/Libraries/LibDebug/ProcessInspector.h b/Userland/Libraries/LibDebug/ProcessInspector.h index d72aac6b65..8247f6bb19 100644 --- a/Userland/Libraries/LibDebug/ProcessInspector.h +++ b/Userland/Libraries/LibDebug/ProcessInspector.h @@ -9,7 +9,7 @@ #include "LoadedLibrary.h" #include <AK/Types.h> -#include <LibC/sys/arch/regs.h> +#include <sys/arch/regs.h> namespace Debug { diff --git a/Userland/Services/SpiceAgent/SpiceAgent.cpp b/Userland/Services/SpiceAgent/SpiceAgent.cpp index da0f97a92b..9119ab84b5 100644 --- a/Userland/Services/SpiceAgent/SpiceAgent.cpp +++ b/Userland/Services/SpiceAgent/SpiceAgent.cpp @@ -7,14 +7,14 @@ #include "SpiceAgent.h" #include "ConnectionToClipboardServer.h" #include <AK/DeprecatedString.h> -#include <LibC/memory.h> -#include <LibC/unistd.h> #include <LibGfx/BMPLoader.h> #include <LibGfx/BMPWriter.h> #include <LibGfx/Bitmap.h> #include <LibGfx/JPGLoader.h> #include <LibGfx/PNGLoader.h> #include <LibGfx/PNGWriter.h> +#include <memory.h> +#include <unistd.h> SpiceAgent::SpiceAgent(int fd, ConnectionToClipboardServer& connection) : m_fd(fd) diff --git a/Userland/Services/SpiceAgent/main.cpp b/Userland/Services/SpiceAgent/main.cpp index 00c7d8aa75..89588df46d 100644 --- a/Userland/Services/SpiceAgent/main.cpp +++ b/Userland/Services/SpiceAgent/main.cpp @@ -5,10 +5,10 @@ */ #include "SpiceAgent.h" -#include <LibC/fcntl.h> #include <LibCore/System.h> #include <LibIPC/ConnectionToServer.h> #include <LibMain/Main.h> +#include <fcntl.h> static constexpr auto SPICE_DEVICE = "/dev/hvc0p1"sv; diff --git a/Userland/Utilities/functrace.cpp b/Userland/Utilities/functrace.cpp index 3bcf652dce..4368ce3575 100644 --- a/Userland/Utilities/functrace.cpp +++ b/Userland/Utilities/functrace.cpp @@ -9,7 +9,6 @@ #include <AK/NonnullOwnPtr.h> #include <AK/StringBuilder.h> #include <Kernel/API/SyscallString.h> -#include <LibC/sys/arch/regs.h> #include <LibCore/ArgsParser.h> #include <LibCore/File.h> #include <LibCore/System.h> @@ -21,6 +20,7 @@ #include <signal.h> #include <stdlib.h> #include <string.h> +#include <sys/arch/regs.h> #include <syscall.h> #include <unistd.h> diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp index 29e29e6ec3..8d34465eb8 100644 --- a/Userland/Utilities/strace.cpp +++ b/Userland/Utilities/strace.cpp @@ -10,7 +10,6 @@ #include <AK/StdLibExtras.h> #include <AK/Types.h> #include <Kernel/API/SyscallString.h> -#include <LibC/sys/arch/regs.h> #include <LibCore/ArgsParser.h> #include <LibCore/Stream.h> #include <LibCore/System.h> @@ -21,6 +20,7 @@ #include <signal.h> #include <stdio.h> #include <string.h> +#include <sys/arch/regs.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <sys/ptrace.h> |