summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-02-23Everywhere: Remove unused RELEASE_ASSERT macroAndreas Kling
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-23AK: Slap Optional with the ALWAYS_INLINE stickAndreas Kling
I saw some Optional constructors when profiling the dynamic loader and that seemed silly since we can inline them at no/little cost.
2021-02-23AK: Optimize StringView::operator==(const char*) a little bitAndreas Kling
Don't compute the strlen() of the string we're comparing against first. This can save a lot of time if we're comparing against something that already fails to match in the first few characters.
2021-02-23AK+Kernel+Userland: Enable some more compiletime format string checksAnotherTest
This enables format string checks for three more functions: - String::formatted() - Builder::appendff() - KBufferBuilder::appendff()
2021-02-23AK+Userland: Extend the compiletime format string check to other functionsAnotherTest
Thanks to @trflynn89 for the neat implicit consteval ctor trick! This allows us to basically slap `CheckedFormatString` on any formatting function, and have its format argument checked at compiletime. Note that there is a validator bug where it doesn't parse inner replaced fields like `{:~>{}}` correctly (what should be 'left align with next argument as size' is parsed as `{:~>{` following a literal closing brace), so the compiletime checks are disabled on these temporarily by forcing them to be StringViews. This commit also removes the now unused `AK::StringLiteral` type (which was introduced for use with NTTP strings).
2021-02-23AK: Untangle TestSuite assertions a bitAnotherTest
2021-02-21AK: Add String{,Utils}::to_snakecase()Linus Groh
This is an improved version of WrapperGenerator's snake_name(), which seems like the kind of thing that could be useful elsewhere but would end up getting duplicated - so let's add this to AK::String instead, like to_{lowercase,uppercase}().
2021-02-21AK: Alter ByteBuffer to utilise memcmp.Ivan Hansgaard Hansen
__builtin_memcmp is already heavily utilised in AK.
2021-02-21AK: Do bounds checking (assertions) in Span::operator[]Andreas Kling
2021-02-21AK: Add an implementation of Array<T, Size>::fill(...)Brian Gianforcaro
2021-02-21AK: Add Span<T> constructor for arraysBrian Gianforcaro
The array constructor allows arrays to be easily treated as generic span of data.
2021-02-21AK: Add safe memset() wrapper to ByteBufferBrian Gianforcaro
In the interest memory safety and of removing as many of foot guns as possible (like raw memset's which are notorious for typo's), a zeroing method seems like a useful utility to have on a buffer class.
2021-02-20LibLine: Avoid refreshing the entire line when inserting at the endAnotherTest
This patchset allows the editor to avoid redrawing the entire line when the changes cause no unrecoverable style updates, and are at the end of the line (this applies to most normal typing situations). Cases that this does not resolve: - When the cursor is not at the end of the buffer - When a display refresh changes the styles on the already-drawn parts of the line - When the prompt has not yet been drawn, or has somehow changed Fixes #5296.
2021-02-20AK: Make Nonnull*PtrVector use size_t for indexesAndreas Kling
This was weird. It turns out these class were using int indexes and sizes despite being derived from Vector which uses size_t. Make the universe right again by using size_t here as well.
2021-02-20AK: Remove unused kprintf macroAndreas Kling
This hasn't been used for quite some time.
2021-02-20AK+LibC: Remove dbgprintf() :^)Andreas Kling
Everything has been moved to dbgln() or other AK::Format-based APIs. We can finally get rid of this old thing.
2021-02-20AK: Add LexicalPath::relative_pathItamar
2021-02-17AK: Publish all_of()Andreas Kling
2021-02-15AK: Mark Optional getters as [[nodiscard]]Brian Gianforcaro
There is no reason to call a getter without observing the result, doing so indicates an error in the code. Mark these methods as [[nodiscard]] to find these cases.
2021-02-14LibCrypto: Make a better ASN.1 parserAnotherTest
And use it to parse RSA keys. As a bonus, this one shouldn't be reading out of bounds or messing with the stack (as much) anymore.
2021-02-14AK: Make the Bitmap::size_in_bytes() member function publicAnotherTest
It's annoying to calculate it when it's already a member function.
2021-02-13AK+Format: Don't cast to size_t when you want u64.Paul Scharnofske
In Serenity, size_t is defined as u32, thus static_cast<size_t>(value) truncates the value.
2021-02-13Utilities: Make syscall(1) explain what it's doingBen Wiederhake
2021-02-12AK: Set DBGLN_NO_COMPILETIME_FORMAT_CHECK for any clang, not just < 12Linus Groh
This currently breaks the OSS-Fuzz build, and attempts to make it build with clang >= 12 were unsuccessful, so let's just disable dbgln() checks for any clang version.
2021-02-12Revert "AK: Fix build with Clang>=12"Linus Groh
This reverts commit 338bb732898dbf68db9554e6a32b4a89ccabb891. This didn't work, the OSS-Fuzz build (using clang 12) is still failing. We'll just disable dbgln() checks when compiling with any clang for now.
2021-02-12AK: Remove operators && and || from DistinctNumericAndreas Kling
These don't do short-circuit evaluation, and so I ran into some some very subtle side-effects when converting code to DistinctNumeric. In code like this: MyDistinctNumeric n; if (n && check_thing(n)) return; There would be no short-circuit evaluation if the return type of check_thing() was implicitly convertible to MyDistinctNumeric. Ran into this while making Ext2FS::GroupIndex a DistinctNumeric.
2021-02-12AK: Add formatter for DistinctNumericAndreas Kling
2021-02-12AK: Allow default-constructing DistinctNumericAndreas Kling
This makes it much more useful as a replacement type for integers. It's zeroed out by default.
2021-02-11LibCore: Added FileWatcher, a binding for the watch_file syscallDexesTTP
This wrapper abstracts the watch_file setup and file handling, and allows using the watch_file events as part of the event loop via the Core::Notifier class. Also renames the existing DirectoryWatcher class to BlockingFileWatcher, and adds support for the Modified mode in this class.
2021-02-10AK: Make IsUnsigned<T> behave as you would expectAndreas Kling
2021-02-10AK: TypeCasts.h should include Assertions.hAndreas Kling
2021-02-10AK: Fix build with Clang>=12AnotherTest
Build failure as in https://oss-fuzz-build-logs.storage.googleapis.com/log-79750138-f41e-4f39-8812-7c536f1d2e35.txt Clang does not appear to like using consteval functions' arguments as constant expressions, so move all the arguments that need to appear as constant expressions into the template parameters for now. This patch should fix the OSS-Fuzz build.
2021-02-09AK: Use StringBuilder::appendff() instead of appendf()Andreas Kling
2021-02-08LibCpp: Include CPP_DEBUG in AK/Debug.hItamar
2021-02-08AK: Add dbgln() format checkingAnotherTest
This checks the following things: - No unclosed braces in format string `dbgln("a:{}}", a)` where the '}}' would be interpreted as a literal '}' `dbgln("a:{", a)` where someone with a faulty keyboard like mine could generate - No extra closed braces in format string `dbgln("a:{{}", a)` where the '{{' would interpreted as a literal '{' `dbgln("a:}", a)` where someone with a faulty keyboard could generate - No references to nonexistent arguments `dbgln("a:{} b:{}", a)` where the value of `b` is not in the arguments list - No unconsumed argument `dbgln("a:{1}", not_used, 1)` where `not_used` is extraneous
2021-02-08Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)AnotherTest
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-02-08AK: Add an iota_array() function that can generate an arrayAnotherTest
...of increasing values with an optional offset.
2021-02-08AK: Clean up includes around printf/vdbgprintfBen Wiederhake
2021-02-08Everywhere: Remove unnecessary headers 4/4Ben Wiederhake
Arbitrarily split up to make git bisect easier. These unnecessary #include's were found by combining an automated tool (which determined likely candidates) and some brain power (which decided whether the #include is also semantically superfluous).
2021-02-08Everywhere: Remove unnecessary headers 3/4Ben Wiederhake
Arbitrarily split up to make git bisect easier. These unnecessary #include's were found by combining an automated tool (which determined likely candidates) and some brain power (which decided whether the #include is also semantically superfluous).
2021-02-08Everywhere: Remove unnecessary headers 2/4Ben Wiederhake
Arbitrarily split up to make git bisect easier. These unnecessary #include's were found by combining an automated tool (which determined likely candidates) and some brain power (which decided whether the #include is also semantically superfluous).
2021-02-08Everywhere: Remove unnecessary headers 1/4Ben Wiederhake
Arbitrarily split up to make git bisect easier. These unnecessary #include's were found by combining an automated tool (which determined likely candidates) and some brain power (which decided whether the #include is also semantically superfluous). My favorite #include: #include "Applications/Piano/Music.h" // You can't have too much music in life!
2021-02-08Everywhere: Fix weird includesBen Wiederhake
2021-02-08AK: remove unused and uninteresting return valueBen Wiederhake
The return value is always be 'count', even in the case of 0. Note that the return value of TypedTransfer::copy() is likewise uninteresting, but apparently it is beig used. Hence this patch does not touch it.
2021-02-07AK: Publish AK::any_of by defaultAndreas Kling
2021-02-05AK: Avoid UB in TypedTransferAndreas Kling
Don't be calling __builtin_memfoo() with null pointer arguments. Found by KUBSAN :^)
2021-02-04Make it possible to overwrite debug macros locally.asynts
Leaking macros across headers is a terrible thing, but I can't think of a better way of achieving this. - We need some way of modifying debug macros from CMake to implement ENABLE_ALL_THE_DEBUG_MACROS. - We need some way of modifying debug macros in specific source files because otherwise we need to rebuild too many files. This was done using the following script: sed -i -E 's/#cmakedefine01 ([A-Z0-9_]+)/#ifndef \1\n\0\n#endif\n/' AK/Debug.h.in sed -i -E 's/#cmakedefine01 ([A-Z0-9_]+)/#ifndef \1\n\0\n#endif\n/' Kernel/Debug.h.in
2021-02-01AK: Make single pivot quick_sort guarantee a max stack depth of log(n)Mart G
- The change to quick_sort requires SimpleIterator to support assignment. - Rename quick_sort to single_pivot_quick_sort to make it easier to choose a specific implementation (not based on signature). - Ensure single_pivot_quick_sort does not copy the pivots - Expand sorts_without_copy test case to cover both single and dual pivot implementations.
2021-01-31AK: Add URL::to_string_encoded()Linus Groh
The result of to_string() passed to urlencode(), with some characters excluded - basically like JavaScript's encodeURI().