mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
n-api: wrap control flow macro in do/while
Make CHECK_ENV() safe to use in the following context:
if (condition)
CHECK_ENV(env);
else
something_else();
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18532
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
1 parent
b565ba2d82
commit
c09a7134e7
1 file changed
+6
-4
+6
-4
@@ -75,10 +75,12 @@ struct napi_env__ {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_ENV(env) \
|
||||
if ((env) == nullptr) { \
|
||||
return napi_invalid_arg; \
|
||||
}
|
||||
#define CHECK_ENV(env) \
|
||||
do { \
|
||||
if ((env) == nullptr) { \
|
||||
return napi_invalid_arg; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_ARG(env, arg) \
|
||||
RETURN_STATUS_IF_FALSE((env), ((arg) != nullptr), napi_invalid_arg)
|
||||
|
||||
Reference in new issue
Block a user