Skip to content
Snippets Groups Projects
Commit 0c52d85e authored by Jonathan Lebon's avatar Jonathan Lebon
Browse files

glnx-errors.h: add glnx_null_throw[_*] variants

These are equivalent to the non-null throw, except that the returned
value is a NULL pointer. They can be used in functions where one wants
to return a pointer. E.g.:

	GKeyFile *foo(GError **error) {
		return glnx_null_throw (error, "foobar");
	}

The function call redirections are wrapped around a compound statement
expression[1] so that they represent a single top-level expression. This
allows us to avoid -Wunused-value warnings vs using a comma operator if
the return value isn't used.

I made the 'args...' absorb the fmt argument as well so that callers can
still use it without always having to specify at least one additional
variadic argument. I had to check to be sure that the expansion is all
done by the preprocessor, so we don't need to worry about stack
intricacies.

[1] https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
parent 602fdd93
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment