On 11/19/2015 01:01 PM, 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 criticial.
typo: 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..16c3a6d 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_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "condition `%s' failed", #x); \
You can replace this line ( spice_log() ) with 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_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "condition `%s' failed", #x); \
Same here.
+ 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"); \
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel