[Spice-devel] [PATCH 2/2] python: Fix -Wsign-compare
Marc-André Lureau
mlureau at redhat.com
Wed Sep 3 03:01:27 PDT 2014
Can limit be negative? Can limit be made unsigned instead?
----- 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