On Tue, Jun 23, 2015 at 03:15:40PM +0000, Morton, Derek J wrote: > > > > > >-----Original Message----- > >From: Daniel Vetter [mailto:daniel.vet...@ffwll.ch] On Behalf Of Daniel > >Vetter > >Sent: Monday, June 15, 2015 3:39 PM > >To: Morton, Derek J > >Cc: intel-gfx@lists.freedesktop.org; Wood, Thomas > >Subject: Re: [Intel-gfx] [PATCH i-g-t v5] libs/igt_core.c: Fix compile > >warnings in igt_core.c > > > >On Fri, Jun 12, 2015 at 11:37:37AM +0100, Derek Morton wrote: > >> Fixed variables incorrectly declared as int instead of size_t. > >> > >> v2: Addressed comments from Tim Gore > >> v3: Removed 'unused parameter' changes > >> v4: Changed to size_t > >> v5: Moved declarations out of for loops > >> > >> Signed-off-by: Derek Morton <derek.j.mor...@intel.com> > >> --- > >> lib/igt_core.c | 18 +++++++++++------- > >> 1 file changed, 11 insertions(+), 7 deletions(-) > >> > >> diff --git a/lib/igt_core.c b/lib/igt_core.c index 8a1a249..eb0cb21 > >> 100644 > >> --- a/lib/igt_core.c > >> +++ b/lib/igt_core.c > >> @@ -1104,7 +1104,9 @@ static pid_t helper_process_pids[] = > >> > >> static void reset_helper_process_list(void) { > >> - for (int i = 0; i < ARRAY_SIZE(helper_process_pids); i++) > >> + size_t i; > >> + > >> + for (i = 0; i < ARRAY_SIZE(helper_process_pids); i++) > > > >I still maintain that your gcc is silly since it's trivial to prove that i > >will fit into an int. > > I don't think your compiler makes any checks to see if it will fit. It would > just silently truncate the data if it did not. This is about good coding > practice in general. Refusing to fix false positives hides real warnings in > the sea of compile routput.
test.c:5:16: warning: comparison is always true due to limited range of data type [-Wtype-limits] for (int i = 0; i < (unsigned)-1; i++) If gcc can do it, why can't your static analyser? -Chris -- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx