• Philip Chimento's avatar
    js: Introduce annotations for using return values · 425b94d6
    Philip Chimento authored
    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".
cairo-path.cpp 3.5 KB