summaryrefslogtreecommitdiff
path: root/gjs/console.cpp
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2018-10-28 20:16:43 -0400
committerPhilip Chimento <philip.chimento@gmail.com>2018-10-30 09:31:44 -0400
commit425b94d663e400b6dee9ed2ebd1c92738970b054 (patch)
tree4518de06c80d37cf6ecf3f1262c4ece1b3839871 /gjs/console.cpp
parentf8672ea2670373171addebd459784a839e08e3ec (diff)
downloadgjs-425b94d663e400b6dee9ed2ebd1c92738970b054.tar.gz
js: Introduce annotations for using return values
This introduces two annotations to functions. GJS_USE is a macro for GCC and Clang's "warn_unused_result" annotation, meaning that the return value of a function must not be ignored. This allows us to catch some cases where we are neglecting to do error checking. The second annotation is GJS_JSAPI_RETURN_CONVENTION which for now is identical to GJS_USE, but could be made into a custom annotation in the future which a static analyzer plugin could use to enforce further checks at compile time. The "JSAPI return convention" is valid on functions that return bool or a pointer type, and whose first parameter is JSContext*. If false or nullptr is returned, then an exception must be pending at return time on the passed-in JSContext. If true or a non-nullptr value is returned, then no exception must be pending. This commit only has the addition of the attributes, and a few fixes mandated by the autoformatter, so it can be reviewed "lightly".
Diffstat (limited to 'gjs/console.cpp')
-rw-r--r--gjs/console.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/gjs/console.cpp b/gjs/console.cpp
index c2c9d524..a110bf31 100644
--- a/gjs/console.cpp
+++ b/gjs/console.cpp
@@ -61,6 +61,7 @@ static GOptionEntry entries[] = {
};
// clang-format on
+GJS_USE
static char **
strndupv(int n,
char * const *strv)
@@ -75,6 +76,7 @@ strndupv(int n,
return retval;
}
+GJS_USE
static char **
strcatv(char **strv1,
char **strv2)