mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
AK: Make Vector::try_* functions return ErrorOr<void>
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. :^)
This commit is contained in:
parent
cd49f30bea
commit
88b6428c25
16 changed files with 98 additions and 152 deletions
|
@ -169,8 +169,7 @@ ErrorOr<FlatPtr> Process::sys$setgroups(size_t count, Userspace<const gid_t*> us
|
|||
}
|
||||
|
||||
Vector<gid_t> new_extra_gids;
|
||||
if (!new_extra_gids.try_resize(count))
|
||||
return ENOMEM;
|
||||
TRY(new_extra_gids.try_resize(count));
|
||||
TRY(copy_n_from_user(new_extra_gids.data(), user_gids, count));
|
||||
|
||||
HashTable<gid_t> unique_extra_gids;
|
||||
|
@ -180,8 +179,7 @@ ErrorOr<FlatPtr> Process::sys$setgroups(size_t count, Userspace<const gid_t*> us
|
|||
}
|
||||
|
||||
ProtectedDataMutationScope scope { *this };
|
||||
if (!m_protected_values.extra_gids.try_resize(unique_extra_gids.size()))
|
||||
return ENOMEM;
|
||||
TRY(m_protected_values.extra_gids.try_resize(unique_extra_gids.size()));
|
||||
size_t i = 0;
|
||||
for (auto& extra_gid : unique_extra_gids) {
|
||||
if (extra_gid == gid())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue