AK: Bring AK::Error into the global namespace
This commit is contained in:
parent
a54be656ae
commit
e5dde37e24
Notes:
sideshowbarker
2024-07-18 01:25:03 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e5dde37e248
3 changed files with 6 additions and 5 deletions
|
@ -117,4 +117,5 @@ struct Formatter<Error> : Formatter<FormatString> {
|
|||
|
||||
}
|
||||
|
||||
using AK::Error;
|
||||
using AK::ErrorOr;
|
||||
|
|
|
@ -32,7 +32,7 @@ ErrorOr<AnonymousBuffer> AnonymousBuffer::create_with_size(size_t size)
|
|||
#if defined(__serenity__)
|
||||
fd = anon_create(round_up_to_power_of_two(size, PAGE_SIZE), O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
return AK::Error::from_errno(errno);
|
||||
return Error::from_errno(errno);
|
||||
#elif defined(__linux__)
|
||||
fd = memfd_create("", MFD_CLOEXEC);
|
||||
if (fd < 0)
|
||||
|
@ -43,7 +43,7 @@ ErrorOr<AnonymousBuffer> AnonymousBuffer::create_with_size(size_t size)
|
|||
}
|
||||
#endif
|
||||
if (fd < 0)
|
||||
return AK::Error::from_errno(errno);
|
||||
return Error::from_errno(errno);
|
||||
return create_from_anon_fd(fd, size);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ ErrorOr<NonnullRefPtr<AnonymousBufferImpl>> AnonymousBufferImpl::create(int fd,
|
|||
{
|
||||
auto* data = mmap(nullptr, round_up_to_power_of_two(size, PAGE_SIZE), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0);
|
||||
if (data == MAP_FAILED)
|
||||
return AK::Error::from_errno(errno);
|
||||
return Error::from_errno(errno);
|
||||
return AK::adopt_nonnull_ref_or_enomem(new (nothrow) AnonymousBufferImpl(fd, size, data));
|
||||
}
|
||||
|
||||
|
|
|
@ -610,7 +610,7 @@ ShareableBitmap Bitmap::to_shareable_bitmap() const
|
|||
ErrorOr<BackingStore> Bitmap::allocate_backing_store(BitmapFormat format, IntSize const& size, int scale_factor)
|
||||
{
|
||||
if (size_would_overflow(format, size, scale_factor))
|
||||
return AK::Error::from_string_literal("Gfx::Bitmap backing store size overflow"sv);
|
||||
return Error::from_string_literal("Gfx::Bitmap backing store size overflow"sv);
|
||||
|
||||
const auto pitch = minimum_pitch(size.width() * scale_factor, format);
|
||||
const auto data_size_in_bytes = size_in_bytes(pitch, size.height() * scale_factor);
|
||||
|
@ -623,7 +623,7 @@ ErrorOr<BackingStore> Bitmap::allocate_backing_store(BitmapFormat format, IntSiz
|
|||
void* data = mmap(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0);
|
||||
#endif
|
||||
if (data == MAP_FAILED)
|
||||
return AK::Error::from_errno(errno);
|
||||
return Error::from_errno(errno);
|
||||
return BackingStore { data, pitch, data_size_in_bytes };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue