Re: [Spice-devel] [spice-common 8/8] log: Let gcc know about the logging macros which abort

2019-03-29 Thread Frediano Ziglio
> On Thu, Mar 28, 2019 at 02:02:58PM -0400, Frediano Ziglio wrote:
> > > 
> > > The for(;;) hack was taken from glib's logging macros.
> > > 
> > > Signed-off-by: Christophe Fergeau 
> > > ---
> > >  common/log.h | 8 
> > >  1 file changed, 8 insertions(+)
> > > 
> > > diff --git a/common/log.h b/common/log.h
> > > index 7c67e7a..b397306 100644
> > > --- a/common/log.h
> > > +++ b/common/log.h
> > > @@ -20,6 +20,7 @@
> > >  
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  
> > > @@ -42,6 +43,7 @@ void spice_log(GLogLevelFlags log_level,
> > >  #define spice_return_if_fail(x) G_STMT_START {
> > >  \
> > >  if G_LIKELY(x) { } else {
> > >  \
> > >  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, G_STRFUNC,
> > >  "condition
> > >  `%s' failed", #x); \
> > > +abort();
> > > \
> > >  return;
> > >  \
> > >  }
> > >  \
> > >  } G_STMT_END
> > > @@ -49,6 +51,7 @@ void spice_log(GLogLevelFlags log_level,
> > >  #define spice_return_val_if_fail(x, val) G_STMT_START {
> > >  \
> > >  if G_LIKELY(x) { } else {
> > >  \
> > >  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__,
> > >  "condition `%s' failed", #x); \
> > > +abort();
> > > \
> > >  return (val);
> > >  \
> > >  }
> > >  \
> > >  } G_STMT_END
> > > @@ -69,12 +72,17 @@ void spice_log(GLogLevelFlags log_level,
> > >  spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, ""
> > >  format, ##
> > >  __VA_ARGS__); \
> > >  } G_STMT_END
> > >  
> > > +/* for(;;) ; so that GCC knows that control doesn't go past g_error().
> > 
> > g_error? copy error?
> > 
> > > + * Put space before ending semicolon to avoid C++ build warnings.
> > > + */
> > >  #define spice_critical(format, ...) G_STMT_START {
> > >  \
> > >  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, ""
> > >  format,
> > >  ## __VA_ARGS__); \
> > > +for (;;) ;
> > 
> > I suppose you can use "for(;;) continue;" and remove the comment (that
> > "continue" was an old suggestion I had, I agree with C++ warning like
> > I agreed at that time with the continue).
> > 
> > Why some are for and some abort?
> 
> Actually, I can't remember, and I haven't been able to reproduce the
> warnings I wanted to fix. I changed all to abort(), which should be
> enough.
> 
> Christophe
> 

I would personally change all to for to avoid the additional include.
If you don't are able to reproduce why "fixing" ?

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Re: [Spice-devel] [spice-common 8/8] log: Let gcc know about the logging macros which abort

2019-03-29 Thread Christophe Fergeau
On Thu, Mar 28, 2019 at 02:02:58PM -0400, Frediano Ziglio wrote:
> > 
> > The for(;;) hack was taken from glib's logging macros.
> > 
> > Signed-off-by: Christophe Fergeau 
> > ---
> >  common/log.h | 8 
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/common/log.h b/common/log.h
> > index 7c67e7a..b397306 100644
> > --- a/common/log.h
> > +++ b/common/log.h
> > @@ -20,6 +20,7 @@
> >  
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  
> > @@ -42,6 +43,7 @@ void spice_log(GLogLevelFlags log_level,
> >  #define spice_return_if_fail(x) G_STMT_START {  \
> >  if G_LIKELY(x) { } else {   \
> >  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, G_STRFUNC, "condition
> >  `%s' failed", #x); \
> > +abort();
> > \
> >  return; \
> >  }   \
> >  } G_STMT_END
> > @@ -49,6 +51,7 @@ void spice_log(GLogLevelFlags log_level,
> >  #define spice_return_val_if_fail(x, val) G_STMT_START { \
> >  if G_LIKELY(x) { } else {   \
> >  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__,
> >  "condition `%s' failed", #x); \
> > +abort();
> > \
> >  return (val);   \
> >  }   \
> >  } G_STMT_END
> > @@ -69,12 +72,17 @@ void spice_log(GLogLevelFlags log_level,
> >  spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "" format, 
> > ##
> >  __VA_ARGS__); \
> >  } G_STMT_END
> >  
> > +/* for(;;) ; so that GCC knows that control doesn't go past g_error().
> 
> g_error? copy error?
> 
> > + * Put space before ending semicolon to avoid C++ build warnings.
> > + */
> >  #define spice_critical(format, ...) G_STMT_START {
> >  \
> >  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "" format,
> >  ## __VA_ARGS__); \
> > +for (;;) ;
> 
> I suppose you can use "for(;;) continue;" and remove the comment (that
> "continue" was an old suggestion I had, I agree with C++ warning like
> I agreed at that time with the continue).
> 
> Why some are for and some abort?

Actually, I can't remember, and I haven't been able to reproduce the
warnings I wanted to fix. I changed all to abort(), which should be
enough.

Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Re: [Spice-devel] [spice-common 8/8] log: Let gcc know about the logging macros which abort

2019-03-28 Thread Frediano Ziglio
> 
> The for(;;) hack was taken from glib's logging macros.
> 
> Signed-off-by: Christophe Fergeau 
> ---
>  common/log.h | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/common/log.h b/common/log.h
> index 7c67e7a..b397306 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -20,6 +20,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -42,6 +43,7 @@ void spice_log(GLogLevelFlags log_level,
>  #define spice_return_if_fail(x) G_STMT_START {  \
>  if G_LIKELY(x) { } else {   \
>  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, G_STRFUNC, "condition
>  `%s' failed", #x); \
> +abort();
> \
>  return; \
>  }   \
>  } G_STMT_END
> @@ -49,6 +51,7 @@ void spice_log(GLogLevelFlags log_level,
>  #define spice_return_val_if_fail(x, val) G_STMT_START { \
>  if G_LIKELY(x) { } else {   \
>  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__,
>  "condition `%s' failed", #x); \
> +abort();
> \
>  return (val);   \
>  }   \
>  } G_STMT_END
> @@ -69,12 +72,17 @@ void spice_log(GLogLevelFlags log_level,
>  spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "" format, ##
>  __VA_ARGS__); \
>  } G_STMT_END
>  
> +/* for(;;) ; so that GCC knows that control doesn't go past g_error().

g_error? copy error?

> + * Put space before ending semicolon to avoid C++ build warnings.
> + */
>  #define spice_critical(format, ...) G_STMT_START {
>  \
>  spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "" format,
>  ## __VA_ARGS__); \
> +for (;;) ;

I suppose you can use "for(;;) continue;" and remove the comment (that
"continue" was an old suggestion I had, I agree with C++ warning like
I agreed at that time with the continue).

Why some are for and some abort?

> \
>  } G_STMT_END
>  
>  #define spice_error(format, ...) G_STMT_START { \
>  spice_log(G_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, "" format, ##
>  __VA_ARGS__); \
> +for (;;) ;
> \
>  } G_STMT_END
>  
>  #define spice_warn_if_fail(x) G_STMT_START {\

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel