From 7ab37ee22cb85820ec73f0677f06125c466feeff Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 7 Jan 2023 13:57:33 -0700 Subject: [PATCH] Everywhere: Remove string.h include from AK/Traits.h and resolve fallout A lot of places were relying on AK/Traits.h to give it strnlen, memcmp, memcpy and other related declarations. In the quest to remove inclusion of LibC headers from Kernel files, deal with all the fallout of this included-everywhere header including less things. --- AK/FuzzyMatch.cpp | 1 + AK/JsonObjectSerializer.h | 4 ++-- AK/PrintfImplementation.h | 2 +- AK/StringUtils.cpp | 5 ++++- AK/Time.h | 11 +++++------ AK/Traits.h | 1 - Kernel/Bus/USB/USBConfiguration.cpp | 1 + Kernel/Bus/USB/USBTransfer.cpp | 1 + Kernel/FileSystem/Ext2FS/Inode.cpp | 6 +++--- Kernel/KBuffer.h | 1 + Kernel/StdLib.h | 2 ++ Userland/Libraries/LibEDID/EDID.cpp | 4 +++- Userland/Libraries/LibELF/Image.cpp | 7 ++++++- Userland/Libraries/LibELF/Validation.cpp | 7 +++++-- 14 files changed, 35 insertions(+), 18 deletions(-) diff --git a/AK/FuzzyMatch.cpp b/AK/FuzzyMatch.cpp index 8a1e313895..f82db25af5 100644 --- a/AK/FuzzyMatch.cpp +++ b/AK/FuzzyMatch.cpp @@ -6,6 +6,7 @@ #include #include +#include namespace AK { diff --git a/AK/JsonObjectSerializer.h b/AK/JsonObjectSerializer.h index d18524843b..518856e66a 100644 --- a/AK/JsonObjectSerializer.h +++ b/AK/JsonObjectSerializer.h @@ -84,11 +84,11 @@ public: TRY(begin_item(key)); if constexpr (IsLegacyBuilder) { TRY(m_builder.try_append('"')); - TRY(m_builder.try_append_escaped_for_json({ value, strlen(value) })); + TRY(m_builder.try_append_escaped_for_json({ value, __builtin_strlen(value) })); TRY(m_builder.try_append('"')); } else { TRY(m_builder.append('"')); - TRY(m_builder.append_escaped_for_json({ value, strlen(value) })); + TRY(m_builder.append_escaped_for_json({ value, __builtin_strlen(value) })); TRY(m_builder.append('"')); } return {}; diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index a1cd9243b0..7953ab074b 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -10,10 +10,10 @@ #include #include #include -#include #ifndef KERNEL # include +# include #endif #ifdef AK_OS_SERENITY diff --git a/AK/StringUtils.cpp b/AK/StringUtils.cpp index 5640be9109..e544d5af77 100644 --- a/AK/StringUtils.cpp +++ b/AK/StringUtils.cpp @@ -14,9 +14,12 @@ #include #include -#ifndef KERNEL +#ifdef KERNEL +# include +#else # include # include +# include #endif namespace AK { diff --git a/AK/Time.h b/AK/Time.h index 0b13b4a48e..8a2382522a 100644 --- a/AK/Time.h +++ b/AK/Time.h @@ -11,12 +11,11 @@ #include #include -// Kernel and Userspace pull in the definitions from different places. -// Avoid trying to figure out which one. -struct timeval; -struct timespec; - -#if defined(AK_OS_WINDOWS) +#if defined(AK_OS_SERENITY) && defined(KERNEL) +# include +# include +#else +# include # include #endif diff --git a/AK/Traits.h b/AK/Traits.h index cdcb9a85f7..901d97ed5d 100644 --- a/AK/Traits.h +++ b/AK/Traits.h @@ -11,7 +11,6 @@ #include #include #include -#include namespace AK { diff --git a/Kernel/Bus/USB/USBConfiguration.cpp b/Kernel/Bus/USB/USBConfiguration.cpp index 93229d1e88..bf913f0006 100644 --- a/Kernel/Bus/USB/USBConfiguration.cpp +++ b/Kernel/Bus/USB/USBConfiguration.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace Kernel::USB { diff --git a/Kernel/Bus/USB/USBTransfer.cpp b/Kernel/Bus/USB/USBTransfer.cpp index ada524d4f0..528df1ae30 100644 --- a/Kernel/Bus/USB/USBTransfer.cpp +++ b/Kernel/Bus/USB/USBTransfer.cpp @@ -6,6 +6,7 @@ #include #include +#include namespace Kernel::USB { diff --git a/Kernel/FileSystem/Ext2FS/Inode.cpp b/Kernel/FileSystem/Ext2FS/Inode.cpp index 9ac62cb7d6..29436f1821 100644 --- a/Kernel/FileSystem/Ext2FS/Inode.cpp +++ b/Kernel/FileSystem/Ext2FS/Inode.cpp @@ -992,11 +992,11 @@ ErrorOr Ext2FSInode::update_timestamps(Optional