[Spice-devel] [spice-common 01/14] quic: Use #define rather than static const int

Frediano Ziglio fziglio at redhat.com
Fri Jul 28 07:45:05 UTC 2017


> 
> On Sat, Jul 22, 2017 at 04:25:59AM -0400, Frediano Ziglio wrote:
> > > 
> > > quic.c is checking at compile-time that 'evol' is 1, 3 or 5. This is a
> > > constant, so a static check should be good, but my compiler (gcc 7.1.1)
> > > is unable to know 'evol' value at compile-time. Since the removal of
> > > spice_static_assert in favour of SPICE_VERIFY, this causes a
> > > compile-time failure.
> > > ---
> > >  common/quic.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/common/quic.c b/common/quic.c
> > > index c188ed2..b7d8347 100644
> > > --- a/common/quic.c
> > > +++ b/common/quic.c
> > > @@ -179,7 +179,7 @@ static const int wmimax = DEFwmimax;
> > >  static const int wminext = DEFwminext;
> > >  
> > >  /* model evolution mode */
> > > -static const int evol = DEFevol;
> > > +#define evol DEFevol
> > >  
> > >  /* bppmask[i] contains i ones as lsb-s */
> > >  static const unsigned long int bppmask[33] = {
> > 
> > Why not using directly DEFevol ?
> 
> Do you mean in the code, ie
> spice_assert(DEFevol < 6); rather than spice_assert(evol < 6);?
> Really went for the minimal fix, no other reason.
> 
> Christophe
> 

I don't see the point to have minimal change here if on the
next patch you are going to change them all anyway.
That's why I suggested using enum as a constant (not considering
was on my stash since I don't remember when).
On the other way looking at all these changes we are basically
fixing some parameters so having two mnemonic for default and
value but knowing that they must the exactly the same is a
bit redundant and confusing.

Frediano


More information about the Spice-devel mailing list