[Spice-devel] [spice-common v2 6/7] log: Introduce spice_assert_if_fail
Frediano Ziglio
fziglio at redhat.com
Mon Nov 30 11:21:18 PST 2015
>
> They can be used in spice-server to replace spice_return_if_fail.
> Currently spice_return_if_fail aborts in spice-server, and it's not
> always clear whether using a non-aborting g_return_if_fail is acceptable
> or not. Having a spice_assert_if_fail alternative makes it clearer that
> this is not going to return, while having a name distinct from assert()
> so that places which needs reviewing can be spotted more easily.
>
> Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
> ---
> Changes since v1:
> - moved indentation change to appropriate commit
>
> common/log.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/common/log.h b/common/log.h
> index c7e6e57..ed9371b 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -95,6 +95,9 @@ void spice_log(const char *log_domain,
> } \
> } G_STMT_END
>
> +#define spice_assert_val_if_fail(cond, val) spice_assert(cond)
> +#define spice_assert_if_fail(cond) spice_assert(cond)
> +
Actually looking just at the code it's not clear why not using
spice_assert directly.
I would copy/move the rationale into a code comment before
these defines
> #define spice_assert(x) G_STMT_START { \
> if G_LIKELY(x) { } else { \
> spice_error("assertion `%s' failed", #x); \
Frediano
More information about the Spice-devel
mailing list