Message ID | 1446464924-20878-8-git-send-email-thomas.wood@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Em Seg, 2015-11-02 às 11:48 +0000, Thomas Wood escreveu: > Initialization was included in commit a976d7e (tests/kms_fbc_crc: > refactor context > handling code), but won't be executed since it is declared before the > first > label within a switch statement. > > kms_fbc_crc.c:178:2: warning: ‘context’ may be used uninitialized in > this function [-Wmaybe-uninitialized] > rendercopy(batch, context, > ^ > kms_fbc_crc.c:271:22: note: ‘context’ was declared here > drm_intel_context *context = NULL; I don't see these warnings here. Which compiler do you use? pzanoni@panetone:~/nfs/intel-gpu-tools/tests$ gcc --version gcc (Debian 5.2.1-22) 5.2.1 20151010 The weird part is that it was initialized during the declaration, so the declaration is valid yet the initialization is not? Anyway, your change removes the ambiguity of the situation and avoid citations of the C standard, so: Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> > > ^ > Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> > Signed-off-by: Thomas Wood <thomas.wood@intel.com> > --- > tests/kms_fbc_crc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c > index d580a94..02e95e5 100644 > --- a/tests/kms_fbc_crc.c > +++ b/tests/kms_fbc_crc.c > @@ -255,6 +255,7 @@ static void test_crc(data_t *data, enum test_mode > mode) > { > uint32_t crtc_id = data->output->config.crtc->crtc_id; > uint32_t handle = data->fb[0].gem_handle; > + drm_intel_context *context = NULL; > > igt_assert(fbc_enabled(data)); > > @@ -268,7 +269,6 @@ static void test_crc(data_t *data, enum test_mode > mode) > } > > switch (mode) { > - drm_intel_context *context = NULL; > case TEST_PAGE_FLIP: > break; > case TEST_MMAP_CPU:
On Wed, Nov 04, 2015 at 07:36:04PM +0000, Zanoni, Paulo R wrote: > Em Seg, 2015-11-02 às 11:48 +0000, Thomas Wood escreveu: > > Initialization was included in commit a976d7e (tests/kms_fbc_crc: > > refactor context > > handling code), but won't be executed since it is declared before the > > first > > label within a switch statement. > > > > kms_fbc_crc.c:178:2: warning: ‘context’ may be used uninitialized in > > this function [-Wmaybe-uninitialized] > > rendercopy(batch, context, > > ^ > > kms_fbc_crc.c:271:22: note: ‘context’ was declared here > > drm_intel_context *context = NULL; > > I don't see these warnings here. Which compiler do you use? > > pzanoni@panetone:~/nfs/intel-gpu-tools/tests$ gcc --version > gcc (Debian 5.2.1-22) 5.2.1 20151010 > > The weird part is that it was initialized during the declaration, so > the declaration is valid yet the initialization is not? Speaking as someone who was bitten by this once, yes that is the case. Would be nice if gcc would flag it as unreachable code. > Anyway, your > change removes the ambiguity of the situation and avoid citations of > the C standard, so: > > Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> > > > > > ^ > > Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> > > Signed-off-by: Thomas Wood <thomas.wood@intel.com> > > --- > > tests/kms_fbc_crc.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c > > index d580a94..02e95e5 100644 > > --- a/tests/kms_fbc_crc.c > > +++ b/tests/kms_fbc_crc.c > > @@ -255,6 +255,7 @@ static void test_crc(data_t *data, enum test_mode > > mode) > > { > > uint32_t crtc_id = data->output->config.crtc->crtc_id; > > uint32_t handle = data->fb[0].gem_handle; > > + drm_intel_context *context = NULL; > > > > igt_assert(fbc_enabled(data)); > > > > @@ -268,7 +269,6 @@ static void test_crc(data_t *data, enum test_mode > > mode) > > } > > > > switch (mode) { > > - drm_intel_context *context = NULL; > > case TEST_PAGE_FLIP: > > break; > > case TEST_MMAP_CPU: > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
On 4 November 2015 at 19:36, Zanoni, Paulo R <paulo.r.zanoni@intel.com> wrote: > Em Seg, 2015-11-02 às 11:48 +0000, Thomas Wood escreveu: >> Initialization was included in commit a976d7e (tests/kms_fbc_crc: >> refactor context >> handling code), but won't be executed since it is declared before the >> first >> label within a switch statement. >> >> kms_fbc_crc.c:178:2: warning: ‘context’ may be used uninitialized in >> this function [-Wmaybe-uninitialized] >> rendercopy(batch, context, >> ^ >> kms_fbc_crc.c:271:22: note: ‘context’ was declared here >> drm_intel_context *context = NULL; > > I don't see these warnings here. Which compiler do you use? The warning requires -Wmaybe-uninitialized and an appropriate optimisation level to be enabled. -Wmaybe-uninitialized is currently disabled by the debug cflags in intel-gpu-tools due to previous false positives, but it looks like the situation with regards to this has improved and so it may be time to re-enable it. > > pzanoni@panetone:~/nfs/intel-gpu-tools/tests$ gcc --version > gcc (Debian 5.2.1-22) 5.2.1 20151010 > > The weird part is that it was initialized during the declaration, so > the declaration is valid yet the initialization is not? Anyway, your > change removes the ambiguity of the situation and avoid citations of > the C standard, so: > > Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> > >> >> ^ >> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> >> Signed-off-by: Thomas Wood <thomas.wood@intel.com> >> --- >> tests/kms_fbc_crc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c >> index d580a94..02e95e5 100644 >> --- a/tests/kms_fbc_crc.c >> +++ b/tests/kms_fbc_crc.c >> @@ -255,6 +255,7 @@ static void test_crc(data_t *data, enum test_mode >> mode) >> { >> uint32_t crtc_id = data->output->config.crtc->crtc_id; >> uint32_t handle = data->fb[0].gem_handle; >> + drm_intel_context *context = NULL; >> >> igt_assert(fbc_enabled(data)); >> >> @@ -268,7 +269,6 @@ static void test_crc(data_t *data, enum test_mode >> mode) >> } >> >> switch (mode) { >> - drm_intel_context *context = NULL; >> case TEST_PAGE_FLIP: >> break; >> case TEST_MMAP_CPU:
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c index d580a94..02e95e5 100644 --- a/tests/kms_fbc_crc.c +++ b/tests/kms_fbc_crc.c @@ -255,6 +255,7 @@ static void test_crc(data_t *data, enum test_mode mode) { uint32_t crtc_id = data->output->config.crtc->crtc_id; uint32_t handle = data->fb[0].gem_handle; + drm_intel_context *context = NULL; igt_assert(fbc_enabled(data)); @@ -268,7 +269,6 @@ static void test_crc(data_t *data, enum test_mode mode) } switch (mode) { - drm_intel_context *context = NULL; case TEST_PAGE_FLIP: break; case TEST_MMAP_CPU:
Initialization was included in commit a976d7e (tests/kms_fbc_crc: refactor context handling code), but won't be executed since it is declared before the first label within a switch statement. kms_fbc_crc.c:178:2: warning: ‘context’ may be used uninitialized in this function [-Wmaybe-uninitialized] rendercopy(batch, context, ^ kms_fbc_crc.c:271:22: note: ‘context’ was declared here drm_intel_context *context = NULL; ^ Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Thomas Wood <thomas.wood@intel.com> --- tests/kms_fbc_crc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)