[Spice-devel] [PATCH spice-common 2/2] log: remove spice_static_assert macro

Marc-André Lureau marcandre.lureau at gmail.com
Thu Aug 10 18:38:23 UTC 2017


On Mon, Jun 12, 2017 at 3:04 PM Marc-André Lureau <
marcandre.lureau at redhat.com> wrote:

> Hi
>
> ----- Original Message -----
> > The macro was misused and not doing static check.
> > Spice have other working static check macros to use.
> > The macro is used only by spice-common so removing it
> > does not cause issues to other depending projects.
> >
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
>
>
> ack
>
> (I wonder why we don't use verify() & verify_expr() directly, but this is
> another discussion)
>


Hmm, gcc -O0 isn't smart enough it seems.. annoying

 In file included from macros.h:22:0,
                 from quic.h:24,
                 from quic.c:28:
quic.c: In function 'find_model_params':
quic.c:881:41: error: expression in static assertion is not constant
     SPICE_VERIFY(evol == 1 || evol == 3 || evol == 5);
                  ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
verify.h:191:23: note: in definition of macro '_GL_VERIFY_TYPE'
       _Static_assert (R, DIAGNOSTIC);          \
                       ^
verify.h:246:5: note: in expansion of macro '_GL_VERIFY_TRUE'
    (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
     ^~~~~~~~~~~~~~~
macros.h:56:28: note: in expansion of macro 'verify_expr'
 #define SPICE_VERIFY(cond) verify_expr(cond, (void)1)
                            ^~~~~~~~~~~
quic.c:881:5: note: in expansion of macro 'SPICE_VERIFY'
     SPICE_VERIFY(evol == 1 || evol == 3 || evol == 5);
     ^~~~~~~~~~~~


> > ---
> >  common/log.h              | 5 -----
> >  common/quic.c             | 2 +-
> >  common/quic_family_tmpl.c | 2 +-
> >  3 files changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/common/log.h b/common/log.h
> > index 1ea2313..a4d296d 100644
> > --- a/common/log.h
> > +++ b/common/log.h
> > @@ -94,11 +94,6 @@ void spice_log(const char *log_domain,
> >      }                                                   \
> >  } G_STMT_END
> >
> > -/* FIXME: improve that some day.. */
> > -#define spice_static_assert(x) SPICE_STMT_START {       \
> > -    spice_assert(x);                                    \
> > -} SPICE_STMT_END
> > -
> >  SPICE_END_DECLS
> >
> >  #endif /* H_SPICE_LOG */
> > diff --git a/common/quic.c b/common/quic.c
> > index 59565ae..2cd1f0d 100644
> > --- a/common/quic.c
> > +++ b/common/quic.c
> > @@ -888,7 +888,7 @@ static void find_model_params(Encoder *encoder,
> >      /* The only valid values are 1, 3 and 5.
> >         0, 2 and 4 are obsolete and the rest of the
> >         values are considered out of the range. */
> > -    spice_static_assert (evol == 1 || evol == 3 || evol == 5);
> > +    SPICE_VERIFY(evol == 1 || evol == 3 || evol == 5);
> >      spice_assert(bpc <= 8 && bpc > 0);
> >
> >      *ncounters = 8;
> > diff --git a/common/quic_family_tmpl.c b/common/quic_family_tmpl.c
> > index 9a434e0..9450f44 100644
> > --- a/common/quic_family_tmpl.c
> > +++ b/common/quic_family_tmpl.c
> > @@ -71,7 +71,7 @@ static unsigned int FNAME(golomb_decoding)(const
> unsigned
> > int l, const unsigned
> >  static void FNAME(update_model)(CommonState *state, s_bucket * const
> bucket,
> >                                  const BYTE curval)
> >  {
> > -    spice_static_assert(BPC >= 1);
> > +    SPICE_VERIFY(BPC >= 1);
> >      spice_return_if_fail (bucket != NULL);
> >
> >      const unsigned int bpp = BPC;
> > --
> > 2.9.4
> >
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> >
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
>
-- 
Marc-André Lureau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170810/21695b11/attachment.html>


More information about the Spice-devel mailing list