[Spice-devel] [PATCH 2/2] python: Fix -Wsign-compare

Fabiano Fidêncio fidencio at redhat.com
Wed Sep 3 03:14:28 PDT 2014


On Wed, 2014-09-03 at 06:01 -0400, Marc-André Lureau wrote:
> Can limit be negative?

I don't think so: http://paste.stg.fedoraproject.org/4623/39072140/

> Can limit be made unsigned instead?

Actually, what I'm doing is making the limit unsigned, thanks for
catching the error in the commit log :-)
I'll rewrite the log and re-submit the patch.

> 
> ----- Original Message -----
> > A few functions are comparing signed and unsigned values, basically
> > because some of the loop indexes are signed values. Casting it to
> > unsigned seems harmless and makes GCC happier.
> > ---
> >  python_modules/codegen.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/python_modules/codegen.py b/python_modules/codegen.py
> > index 009cf95..603531f 100644
> > --- a/python_modules/codegen.py
> > +++ b/python_modules/codegen.py
> > @@ -266,7 +266,7 @@ class CodeWriter:
> >          return self.block()
> >  
> >      def for_loop(self, index, limit):
> > -        return self.block("for (%s = 0; %s < %s; %s++)" % (index, index,
> > limit, index))
> > +        return self.block("for (%s = 0; %s < (unsigned) %s; %s++)" % (index,
> > index, limit, index))
> >  
> >      def while_loop(self, expr):
> >          return self.block("while (%s)" % (expr))
> > --
> > 1.9.3
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel
> > 




More information about the Spice-devel mailing list