[Intel-gfx] [PATCH i-g-t] libs/igt_core.c: Fix compile warnings in igt_core.c

Daniel Vetter daniel at ffwll.ch
Wed May 20 02:19:14 PDT 2015


On Wed, May 20, 2015 at 08:37:56AM +0000, Morton, Derek J wrote:
> >> > -----Original Message-----
> >> > From: Morton, Derek J
> >> > Sent: Tuesday, May 19, 2015 12:21 PM
> >> > To: intel-gfx at lists.freedesktop.org
> >> > Cc: Wood, Thomas; Gore, Tim; Morton, Derek J
> >> > Subject: [PATCH i-g-t] libs/igt_core.c: Fix compile warnings in 
> >> > igt_core.c
> >> > 
> >> > Fixed variables incorrectly declared as signed instead of unsigned.
> >
> >Which kind of compiler warning is this? Imo
> >
> >	for (unsigned int i = 0; i < something; i++)
> >
> >is just not C style, the int there is perfectly fine. We've had this problem before with Android going ridiculously overboard with >compiler warnings, and the solution back then was to remove all the silly ones for igt. It smells like the same is appropriate for this >one here too.
> >
> 
> The warning occurs because 'something' is of an unsigned type. In this
> case the macro ARRAY_SIZE uses sizeof() which returns an unsigned type.
> Implicit conversion between signed and unsigned types has always
> resulted in compiler warnings in my experience. It is not something
> android specific.

I don't have them here when building igt, and ARRAY_SIZE is also
extensively used in the kernel, also with size_of. This really sounds like
Android again going overboard with enabling compiler warnings to me.

Also the warning is silly here, since ARRAY_SIZE is statically known and
gcc can figure out that there's no overflow possible. The warning level in
kernel is such that you get overflow warnings only when gcc can prove that
there's an overflow. Which makes sense, but this here imo really doesn't.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list