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

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

 



> 
> Hi
> 
> ----- Original Message -----
> > 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.
> > This is also compatible with Glib macros.
> 
> Why not start using glib macros instead?
> 

starting would mean:
- have half call to old and half to new with 2 different behavior);
- switch all to glib changing behavior and making hard to switch back.

Adding new macros more compatible with glib but 100% compatible with current
code make the transition more smooth.

For instance we could change the assert to spice_return_*warning now knowing
that we can safely convert to g_return* in the future.

Frediano

> > 
> > 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); \
> > +        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); \
> > +        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]