Re: [PATCH] log: add not fatal spice_return function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2015-11-20 at 12:31 +0000, Frediano Ziglio wrote:
> Due to implementation details spice_return is by default fatal (program
> is aborting). This is quite confusing but changing the current macros
> would possibly break existing code.
> Add not fatal (at least by default) macros. They use warning level
> instead of critical.
> This is also compatible with Glib macros.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  common/log.h | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/common/log.h b/common/log.h
> index d9e6023..fdfdfa4 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -73,6 +73,24 @@ void spice_log(const char *log_domain,
>  } SPICE_STMT_END
>  #endif
>  
> +#ifndef spice_return_if_fail_warning
> +#define spice_return_if_fail_warning(x) SPICE_STMT_START {              \
> +    if SPICE_LIKELY(x) { } else {                                       \
> +        spice_warning("condition `%s' failed", #x);                     \
> +        return;                                                         \
> +    }                                                                   \
> +} SPICE_STMT_END
> +#endif
> +
> +#ifndef spice_return_val_if_fail_warning
> +#define spice_return_val_if_fail_warning(x, val) SPICE_STMT_START {     \
> +    if SPICE_LIKELY(x) { } else {                                       \
> +        spice_warning("condition `%s' failed", #x);                     \
> +        return (val);                                                   \
> +    }                                                                   \
> +} SPICE_STMT_END
> +#endif
> +
>  #ifndef spice_warn_if_reached
>  #define spice_warn_if_reached() SPICE_STMT_START {                      \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC,
> __FUNCTION__, "should not be reached"); \


I don't know. I think I agree with Christophe and Marc-Andre that adding more
spice-specific logging functions just confuses the issue. I'd rather just use
g_return_if_fail for new code and gradually go through all other uses of
spice_return_if and either convert them to g_return_if or to spice_assert.


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]