mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:37:35 +00:00
AK+Everywhere: Disallow returning a reference from a fallible expression
This will silently make a copy. Rather than masking this behavior, let's explicitly disallow it.
This commit is contained in:
parent
3de75f6436
commit
afc0e461e1
11 changed files with 86 additions and 54 deletions
|
@ -184,12 +184,14 @@ private:
|
|||
};
|
||||
|
||||
// This is a special variant of TRY() that also updates the socket's SO_ERROR field on error.
|
||||
#define SOCKET_TRY(expression) \
|
||||
({ \
|
||||
auto result = (expression); \
|
||||
if (result.is_error()) \
|
||||
return set_so_error(result.release_error()); \
|
||||
result.release_value(); \
|
||||
#define SOCKET_TRY(expression) \
|
||||
({ \
|
||||
auto result = (expression); \
|
||||
if (result.is_error()) \
|
||||
return set_so_error(result.release_error()); \
|
||||
static_assert(!IsLvalueReference<decltype(result.release_value())>, \
|
||||
"Do not return a reference from a fallible expression"); \
|
||||
result.release_value(); \
|
||||
})
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue