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

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

 



Hi,

On Thu, Nov 19, 2015 at 02:41:52PM +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..bb5035b 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 {                      \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
Extra tab here?

> +    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 {             \

Same!

Patch looks good to me.
  - toso

> +    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"); \
> -- 
> 2.4.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
_______________________________________________
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]