Commit Graph

29793 Commits

Author SHA1 Message Date
Andreas Kling
0f5477c721 AK: Use ErrorOr<T> for MappedFile factories
Replace Result<T, E> with ErrorOr<T> and propagate the error to callers.
2021-11-08 00:35:27 +01:00
Andreas Kling
c837bd551e AK: Don't define ENABLE_COMPILETIME_FORMAT_CHECK when parsed by CLion 2021-11-08 00:35:27 +01:00
Andreas Kling
880964755b AK: Don't define AK_HAS_CONDITIONALLY_TRIVIAL when parsed by CLion IDE
This feature confuses CLion's parser, so let's turn it off if we see the
__CLION_IDE_ macro as well.
2021-11-08 00:35:27 +01:00
Andreas Kling
202950bb01 AK: Make Error and ErrorOr<T> work in Lagom as well :^)
ErrnoCode is not a thing outside __serenity__, so let's not make
assumptions about it existing.
2021-11-08 00:35:27 +01:00
Andreas Kling
6e255b262f LibGfx: Use ErrorOr<T> for try_create_from_serialized_byte_buffer() 2021-11-08 00:35:27 +01:00
Andreas Kling
0de33b3d6c LibGfx: Use ErrorOr<T> for Bitmap::try_create()
Another one that was used in a fajillion places.
2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Andreas Kling
16f064d9be LibGfx: Convert Gfx::Bitmap to east const style 2021-11-08 00:35:27 +01:00
Andreas Kling
d85d741c59 LibGfx: Deduplicate code in Bitmap::try_load_from_file()
This can share logic with try_load_from_fd_and_close(), we just need to
open the file first. :^)
2021-11-08 00:35:27 +01:00
Andreas Kling
09cba7c780 LibGfx: Use ErrorOr<T> for Bitmap infrastructure used by ShareableBitmap
This also allows us to get rid of the ShareableBitmap(Bitmap)
constructor which was easy to misuse. Everyone now uses Bitmap's
to_shareable_bitmap() helper instead.
2021-11-08 00:35:27 +01:00
Andreas Kling
8262bbf624 LibGfx: Use ErrorOr<T> for Bitmap::cropped() 2021-11-08 00:35:27 +01:00
Andreas Kling
5e41c70e83 LibGfx: Use ErrorOr<T> for Bitmap::scaled() 2021-11-08 00:35:27 +01:00
Andreas Kling
db90b4554e LibGfx: Use ErrorOr<T> for Bitmap::flipped() 2021-11-08 00:35:27 +01:00
Andreas Kling
69c4614a94 LibGfx: Use ErrorOr<T> for Bitmap::rotated() 2021-11-08 00:35:27 +01:00
Andreas Kling
2da4cfcc80 LibGfx: Use ErrorOr<T> for Bitmap::clone() 2021-11-08 00:35:27 +01:00
Andreas Kling
c417820bff LibGfx: Use ErrorOr<T> for Bitmap::try_create_shareable() 2021-11-08 00:35:27 +01:00
Andreas Kling
83d1460ee8 LibGfx: Use ErrorOr<T> for Bitmap::try_create_wrapper() 2021-11-08 00:35:27 +01:00
Andreas Kling
2116620db8 AK: Add ErrorOr<T>::release_value_but_fixme_should_propagate_errors()
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-08 00:35:27 +01:00
Andreas Kling
f23f99d51b LibGfx: Use ErrorOr<T> for Bitmap::try_create_with_anonymous_buffer() 2021-11-08 00:35:27 +01:00
Andreas Kling
c6b4e7a2f6 LibIPC: Add ClientConnection::shutdown_with_error()
Before this, we only had ClientConnection::did_misbehave() to report an
error and shut the connection down. But it's not fair to say that *all*
errors are the client misbehaving! A typical non-misbehavior is resource
allocation failure on the server side.
2021-11-08 00:35:27 +01:00
Andreas Kling
e5dde37e24 AK: Bring AK::Error into the global namespace 2021-11-08 00:35:27 +01:00
Andreas Kling
a54be656ae LibRegex: Don't push LibRegex's "Error" into the global namespace 2021-11-08 00:35:27 +01:00
Andreas Kling
af562c857e LibGfx: Use ErrorOr<T> for Gfx::Bitmap::allocate_backing_store() 2021-11-08 00:35:27 +01:00
Andreas Kling
56992f90b7 AK: Add adopt_nonnull_ref_or_enomem() for userspace
We already had this mechanism in the kernel. Let's have it in userspace
as well. This return an ErrorOr<NonnullRefPt<T>>. :^)
2021-11-08 00:35:27 +01:00
Andreas Kling
e2eabb4132 LibCore: Use ErrorOr<T> in Core::AnonymousBuffer 2021-11-08 00:35:27 +01:00
Andreas Kling
c4edb9f6c2 AK: Add Error and ErrorOr<T>
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)
2021-11-08 00:35:27 +01:00
Ben Wiederhake
99b8750154 syscall: Translate errno to something human-readable 2021-11-08 00:34:58 +01:00
Ben Wiederhake
c706b2c142 hexdump: Improve error handling
In particular, hexdump can now handle read errors and reads that
completely fill up the buffer.
2021-11-08 00:34:58 +01:00
Ben Wiederhake
3582184d8c Kernel: Expose inode information in /proc/pid/fds 2021-11-08 00:34:58 +01:00
Karol Kosek
657409736a WidgetGallery: Make custom cursors visible only in the cursors tab
Prior to this change, the selected cursor stayed changed throughout
the app, even after switching tabs, which didn't look quite right.
2021-11-08 00:06:55 +01:00
Hendiadyoin1
2867d93115 UserspaceEmulator: Improve the MMX formatting on environment dump 2021-11-07 22:42:23 +00:00
Hendiadyoin1
83f50a1507 UserspaceEmulator: Raise an error on FPU stack underflow
Accessing an unset part of the FPU stack should not be a simple warning,
but should trigger the FPU exception mechanism.
2021-11-07 22:42:23 +00:00
Hendiadyoin1
0d6d780183 UserspaceEmulator: Remove some unnecessary casting 2021-11-07 22:42:23 +00:00
Hendiadyoin1
d759175767 UserspaceEmulator: Stop overriding flags in FCOMI
We no longer override the flags we just set. We now also unset of, af,
and sf after the comparison.
This fixes the asin function for LibM!
2021-11-07 22:42:23 +00:00
Hendiadyoin1
f2eff767a0 UserspaceEmulator: Fix typos in SoftFPU.[cpp|h] 2021-11-07 22:42:23 +00:00
Hendiadyoin1
74aba07b70 UserspaceEmulator: Align FPU-exception names with the manual 2021-11-07 22:42:23 +00:00
Hendiadyoin1
5d2a4bd18d UserspaceEmulator: Check the right flags in FCMOV
Also make FCMOVNB do an actual CMOV and not a copy of FILD_m32
2021-11-07 22:42:23 +00:00
Hendiadyoin1
8108aaca39 UserspaceEmulator: Correct FSCALES rounding
We were rounding the wrong way, FSCALE is supposed to trunc internally,
while we were flooring.
Now LibM exponentials and related tests work :^)
2021-11-07 22:42:23 +00:00
Hendiadyoin1
fa02b46295 UserspaceEmulator: Always set C1 when rounding 2021-11-07 22:42:23 +00:00
Hendiadyoin1
7214b08f81 UserspaceEmulator: Simplify the definition of the FPU register stack
Long doubles are always at least 80 bits wide in memory and it suffices
if we can address these 80 bits, to mark the long double as NAN at the
end of an MMX instruction, so the additional magic using conditional
types is unnecessary.
2021-11-07 22:42:23 +00:00
Hendiadyoin1
d06675e3e4 UserspaceEmulator: Use unsigned types for logical MMX shifting 2021-11-07 22:42:23 +00:00
Linus Groh
a3b8303f3c LibJS: Fix modulo() template argument deduction on i686
Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp:283:24:
    note: deduced conflicting types for parameter 'T' ('long long int'
    and 'long int')
      283 |     nanosecond = modulo(nanosecond, 1000l);
          |                  ~~~~~~^~~~~~~~~~~~~~~~~~~

Worked fine on x86_84 :yakshrug:
2021-11-07 21:33:56 +00:00
Linus Groh
b3ea7332b2 LibJS: Fix use of "modulo" for negative values in balance_time() 2021-11-07 21:11:31 +00:00
Linus Groh
3d84fb64c3 LibJS: Add a modulo() function to represent the "x modulo y" notation
This *not* being the same as C++ "%" in all cases is a massive footgun,
and hopefully one I came across for the last time.
2021-11-07 21:11:31 +00:00
Linus Groh
e93ce1ff69 LibJS: Fix nanoseconds formatting in format_time_zone_offset_string()
Two issues:

- The format string said "{:9}", which left-pads with spaces and not
  zeros as required
- Even when correcting that, we were not accounting for step 11 b:
  "Set fraction to the longest possible substring of fraction starting
  at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO)."
  We can safely use trim() for that as the formatted string is known to
  not contain only zeros (which would leave the left-most in place).

Also adds tests for "UTC" and various numeric offsets.
2021-11-07 20:06:28 +00:00
Linus Groh
68d80d239b LibJS: Fix fraction substring in parse_time_zone_offset_string()
We're supposed to get the substring from `fraction`, which is guaranteed
to have the required length. `fraction_part` is the user-supplied value
and trying to get a substring view from 0-9 might crash.
2021-11-07 20:01:31 +00:00
Linus Groh
df2ccb3d38 LibJS: Implement Temporal.Duration.prototype.toLocaleString() 2021-11-07 15:31:28 +01:00
Linus Groh
90fa356b93 LibJS: Implement Temporal.Duration.prototype.toJSON() 2021-11-07 15:31:28 +01:00
Linus Groh
b2548393d2 LibJS: Implement Temporal.Duration.prototype.toString()
I hereby claim "implemented largest AO in LibJS ever" (450 lines). :^)
2021-11-07 15:31:28 +01:00
Linus Groh
36b51276d5 LibJS: Change calendar_date_add() date parameter from PlainDate to Value
Turns out use of this AO is a bit more flexible than I anticipated.
2021-11-07 15:31:28 +01:00