summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-11-18AK: Make RedBlackTree::try_insert() return ErrorOr<void> instead of boolAndreas Kling
2021-11-18AK: Implement `acos<T>` correctlyJelle Raaijmakers
This is a naive implementation based on the symmetry with `asin`. Before, I'm not really sure what we were doing, but it was returning wildly incorrect results.
2021-11-17AK: Add missing return in Formatter<unsigned char[Size]>::format()Andreas Kling
Caught by ENABLE_ALL_THE_DEBUG_MACROS.
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
2021-11-17AK: Add failable try_* functions to StringBuilderAndreas Kling
These will allow us to start using TRY() with StringBuilder operations.
2021-11-17AK: Forward declare Error and ErrorOr in AK/Forward.hAndreas Kling
2021-11-17AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)Andreas Kling
Also add slightly richer parse errors now that we can include a string literal with returned errors. This will allow us to use TRY() when working with JSON data.
2021-11-16AK: Verify that we are not overreaching in StringView's substring_view()Hendiadyoin1
2021-11-16AK+Kernel: Remove implicit conversion from Userspace<T*> to FlatPtrAndrew Kaster
This feels like it was a refactor transition kind of conversion. The places that were relying on it can easily be changed to explicitly ask for the ptr() or a new vaddr() method on Userspace<T*>. FlatPtr can still implicitly convert to Userspace<T> because the constructor is not explicit, but there's quite a few more places that are relying on that conversion.
2021-11-14AK: Resolve clang-tidy readability-const-return-type warning in BitmapAndrew Kaster
Returning a const BitmapView doesn't make much sense :^)
2021-11-14AK: Suppress false positive readability-non-const-parameter in FunctionAndrew Kaster
In AK::Function::CallableWrapper::init_and_swap(), clang-tidy wants us to mark the destination argument as pointer to const, which doesn't work because we use placement new to construct a move'd *this into.
2021-11-14AK+Kernel: Suppress clang-tidy warnings from the cert-* categoryAndrew Kaster
cert-dcl50-cpp: No variadic functions, suppressed in RefCounted and ThreadSafeRefCounted for implementing the magic one_ref_left and will_be_destroyed functions. cert-dcl58-cpp: No opening ::std, suppressed in the places we put names in ::std to aid tools (move, forward, nullptr_t, align_val_t, etc).
2021-11-14AK: Avoid implicit conversion clang-tidy warnings in AK::TimeAndrew Kaster
2021-11-14AK: Move StandardFormatter argument into base class initializerAndrew Kaster
Subclasses of StandardFormatter don't need to use the formatter argument in their constructor, so move() it into the base class initializer.
2021-11-14AK: Avoid implicit conversions in TypeErasedParameter::to_size()Andrew Kaster
Refactor to a visitor+functor pattern that does an explicit static_cast to size_t after performing suitable range checks for each type.
2021-11-14AK: Resolve clang-tidy readability-qualified-auto warningsAndrew Kaster
... In files included by Kernel/Process.cpp and Kernel/Thread.cpp
2021-11-14AK: Mark StringView::find_any_of() as constAndrew Kaster
2021-11-14AK: Resolve clang-tidy warnings about unusual assignment operatorsAndrew Kaster
Either not returning *this, or in the case of Variant, not checking for self assignment. In AK::Atomic, we can't return *this due to the wrapper semantics Atomic implements.
2021-11-14AK: Resolve clang-tidy readability-bool-conversion warningsAndrew Kaster
... In files included by Kernel/Process.cpp and Kernel/Thread.cpp
2021-11-14AK: Use capitalized literal suffixes for AK::abs() overloadsAndrew Kaster
Using `l` for long double causes a clang-tidy warning, so use all caps suffixes for all of the AK::abs() overloads for consistency. Also, avoid leaking the internal __DEFINE_GENERIC_ABS macro.
2021-11-14AK: Avoid else after return in files commonly included by the KernelAndrew Kaster
2021-11-14AK: Use proper type for bool NumericLimits::min and max specializationAndrew Kaster
We had these declared as returning char, which looks like a copy paste error. Found by clang-tidy.
2021-11-14AK: Suppress false-positive clang-tidy warning in Assertions.hAndrew Kaster
The definition of VERIFY_NOT_REACHED() as `assert(false)` causes the tool to suggest converting it to a static_assert. Which doesn't make any sense in context for what the macro is trying to do: crash the program at runtime.
2021-11-14Meta: Add basic clang-tidy configurationAndrew Kaster
Add a basic clang-tidy configuration that enables checks from the following categories: - bugprone - cert - clang-analyzer - concurrency - misc - performance - portability - readability The noisiest rules that have conflicts with the project style guide or accepted practices have been turned off. There's absolutely more work to be done here before we could consider setting any of these warnings as errors and enforcing them in CI, but committing a project clang-tidy configuration should help the rules become more visible and let other contributors take a crack at tweaking rules and/or finding possible bugs. Sadly the cpp-core-guidelines and modernize categories are very, very noisy. If we want to enable rules from these categories, they would need to be on a rule by rule basis.
2021-11-14AK: Swallow 'L' format specifier until it is properly implementedBrian Gianforcaro
Previously if code attempted to use the format specifier somewhere (Ex: "%#4.3Lg"), the specifier would get dropped and we would just print "g" instead of any value. Now at least we print a value.
2021-11-11LibWasm: Implement module validationAli Mohammad Pur
2021-11-11AK: Allow to clear HashTables/Maps with capacityHendiadyoin1
2021-11-11Everywhere: Pass AK::ReadonlyBytes by valueAndreas Kling
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-11AK: Make HashTable and HashMap try_* functions return ErrorOr<T>Andreas Kling
This allows us to use TRY() and MUST() with them.
2021-11-10AK: Make ByteBuffer::try_* functions return ErrorOr<void>Andreas Kling
Same as Vector, ByteBuffer now also signals allocation failure by returning an ENOMEM Error instead of a bool, allowing us to use the TRY() and MUST() patterns.
2021-11-10AK: Make Vector::try_* functions return ErrorOr<void>Andreas Kling
Instead of signalling allocation failure with a bool return value (false), we now use ErrorOr<void> and return ENOMEM as appropriate. This allows us to use TRY() and MUST() with Vector. :^)
2021-11-10AK+LibJS: Simplify MUST() and move it from LibJS to AK/Try.hAndreas Kling
This is generally useful so let's move it to AK. Also it seems that we don't need the temporary variable hack anymore, so let's lose that.
2021-11-10AK+Everywhere: Stop including Vector.h from StringView.hAndreas Kling
Preparation for using Error.h from Vector.h. This required moving some things out of line.
2021-11-10AK: Properly declare inheritance of Bitmap from BitmapViewBen Wiederhake
All the read-only methods of Bitmap simply defer to BitmapView. Let's make this relationship official by using class inheritance. This might even shave off a few instructions, although any sufficiently optimizing compiler probably already optimized them away.
2021-11-10AK+Kernel: Make BitmapView read-onlyBen Wiederhake
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-11-08AK: Add some more ways to construct Error and ErrorOr<T>Andreas Kling
This is preparation for using Error in the kernel instead of KResult.
2021-11-08AK: Make Error.h pull in Try.hAndreas Kling
Users of this API will want TRY().
2021-11-08AK: Add a variant of adopt_nonnull_own_or_enomem() for userspaceAndreas Kling
This variant returns ErrorOr<NonnullOwnPtr<T>> instead of KResultOr. Eventually the KResultOr variant should go away once the kernel adopts Error and ErrorOr<T>.
2021-11-08AK: Remove now-unused OSError classAndreas Kling
This has been superseded by the more generally useful AK::Error :^)
2021-11-08AK: Allow subclassing ErrorAndreas Kling
2021-11-08AK: Use ErrorOr<T> for MappedFile factoriesAndreas Kling
Replace Result<T, E> with ErrorOr<T> and propagate the error to callers.
2021-11-08AK: Don't define ENABLE_COMPILETIME_FORMAT_CHECK when parsed by CLionAndreas Kling
2021-11-08AK: Don't define AK_HAS_CONDITIONALLY_TRIVIAL when parsed by CLion IDEAndreas Kling
This feature confuses CLion's parser, so let's turn it off if we see the __CLION_IDE_ macro as well.
2021-11-08AK: Make Error and ErrorOr<T> work in Lagom as well :^)Andreas Kling
ErrnoCode is not a thing outside __serenity__, so let's not make assumptions about it existing.
2021-11-08AK: Add ErrorOr<T>::release_value_but_fixme_should_propagate_errors()Andreas Kling
This is an alternative to ErrorOr<T>::release_value() that can be used when converting code to signal that we're releasing the value without error propagation as a way to move forward now. This makes these cases much easier to find later on, once more paths for error propagation are available.
2021-11-08AK: Bring AK::Error into the global namespaceAndreas Kling
2021-11-08AK: Add adopt_nonnull_ref_or_enomem() for userspaceAndreas Kling
We already had this mechanism in the kernel. Let's have it in userspace as well. This return an ErrorOr<NonnullRefPt<T>>. :^)
2021-11-08AK: Add Error and ErrorOr<T>Andreas Kling
The goal with these is to eventually replace AK::Result, KResult and KResultOr<T> with something that works (and makes sense) in both kernel and userspace. This first cut of Error can be made from an errno code, or from a string literal (StringView)