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

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


On Wed, 2014-09-03 at 06:22 -0400, Marc-André Lureau wrote:
> 
> ----- Original Message -----
> > 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.
> 
> No, I mean the argument passed as the limit to for_loop(self, index, limit)
> 
> ex: *__nelements, n_ptr etc
> 
> If those value can be negative, we need a check before entering the for loop with the (unsigned) cast.

The most part of the values are already unsigned values. The exceptions,
that are causing the warnings, are:

generated_server_marshallers.c:1387:27: warning: comparison between
signed and unsigned integer expressions [-Wsign-compare]
             for (j = 0; j < (((src2->width + 7) / 8 ) * src2->height);
j++) {
                           ^
generated_server_marshallers.c:1411:27: warning: comparison between
signed and unsigned integer expressions [-Wsign-compare]
             for (j = 0; j < (((4 * src2->width + 7) / 8 ) *
src2->height); j++) {
                           ^
generated_server_marshallers.c:1435:27: warning: comparison between
signed and unsigned integer expressions [-Wsign-compare]
             for (j = 0; j < (src2->width * src2->height); j++) {

And those cannot be negative.

Best Regards,
--
Fabiano Fidêncio



More information about the Spice-devel mailing list