mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-17 09:20:28 +03:00
Everywhere: Remove "LibC/" includes, add lint-rule against it
This commit is contained in:
parent
d575cfda61
commit
3281050359
Notes:
sideshowbarker
2024-07-17 07:19:27 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/3281050359 Pull-request: https://github.com/SerenityOS/serenity/pull/16791 Reviewed-by: https://github.com/ADKaster ✅
@ -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>
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <LibC/mallocdefs.h>
|
||||
#include <mallocdefs.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static constexpr size_t runs = 5000;
|
||||
|
@ -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>
|
||||
|
@ -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)
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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..
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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**)
|
||||
{
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "LoadedLibrary.h"
|
||||
#include <AK/Types.h>
|
||||
#include <LibC/sys/arch/regs.h>
|
||||
#include <sys/arch/regs.h>
|
||||
|
||||
namespace Debug {
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user